* {
    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;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    max-width: 1400px;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: start;
}

.game-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.settings-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-height: 80vh;
    overflow-y: auto;
}

h1 {
    color: #776e65;
    font-size: 60px;
    margin-bottom: 20px;
    text-align: center;
}

.info-bar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.score-container {
    background: #bbada0;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-align: center;
    min-width: 100px;
}

.score-label {
    font-size: 12px;
    text-transform: uppercase;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

button {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #8f7a66;
    color: white;
}

.btn-primary:hover {
    background: #9f8a76;
}

.btn-success {
    background: #4caf50;
    color: white;
}

.btn-success:hover {
    background: #66bb6a;
}

.btn-danger {
    background: #f44336;
    color: white;
}

.btn-danger:hover {
    background: #e57373;
}

.direction-display {
    background: #ffeaa7;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    color: #2d3436;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.direction-arrow {
    font-size: 30px;
    margin: 0 10px;
}

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

.tile {
    background: #cdc1b4;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    font-weight: bold;
    color: #776e65;
    position: relative;
    transition: all 0.15s ease-in-out;
    overflow: hidden;
}

.tile.new {
    animation: appear 0.2s;
}

.tile.merged {
    animation: pop 0.2s;
}

.tile-gif {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.7;
    z-index: 0;
}

.tile-value {
    position: relative;
    z-index: 1;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.5);
}

@keyframes appear {
    0% {
        transform: scale(0);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pop {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.tile-2 { background: #eee4da; color: #776e65; }
.tile-4 { background: #ede0c8; color: #776e65; }
.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; font-size: 35px; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 35px; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 35px; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 30px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 30px; }
.tile-4096 { background: #3c3a32; color: #f9f6f2; font-size: 25px; }

.game-over {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(238, 228, 218, 0.95);
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    display: none;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.game-over.active {
    display: block;
}

.game-over h2 {
    font-size: 48px;
    color: #776e65;
    margin-bottom: 20px;
}

h2 {
    color: #776e65;
    margin-bottom: 20px;
    font-size: 24px;
}

.gif-input-group {
    margin-bottom: 15px;
}

.gif-input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #776e65;
}

.gif-input-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #bbada0;
    border-radius: 5px;
    font-size: 14px;
}

.gif-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
}

.gif-preview img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    border: 2px solid #bbada0;
}

.status-message {
    background: #74b9ff;
    color: white;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
    font-weight: bold;
}

@media (max-width: 1200px) {
    .container {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 40px;
    }

    .tile {
        font-size: 30px;
    }

    .tile-128, .tile-256, .tile-512 {
        font-size: 25px;
    }

    .tile-1024, .tile-2048 {
        font-size: 20px;
    }
}

/* GIF Search styles */
.gif-input-row {
    display: flex;
    gap: 8px;
}

.gif-input-row input {
    flex: 1;
}

.btn-search {
    background: #74b9ff;
    color: white;
    padding: 10px 15px;
    font-size: 14px;
    white-space: nowrap;
}

.btn-search:hover {
    background: #0984e3;
}

.gif-search-modal {
    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: 2000;
}

.gif-search-modal.active {
    display: flex;
}

.gif-search-content {
    background: white;
    border-radius: 15px;
    padding: 25px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.gif-search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.gif-search-header h3 {
    color: #776e65;
    font-size: 20px;
}

.btn-close {
    background: none;
    border: none;
    font-size: 30px;
    color: #776e65;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.btn-close:hover {
    color: #f44336;
}

.gif-search-input-row {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.gif-search-input-row input {
    flex: 1;
    padding: 12px;
    border: 2px solid #bbada0;
    border-radius: 5px;
    font-size: 16px;
}

.gif-search-status {
    text-align: center;
    color: #776e65;
    font-size: 14px;
    margin-bottom: 10px;
}

.gif-search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.gif-result-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.2s;
}

.gif-result-item:hover {
    border-color: #74b9ff;
    transform: scale(1.05);
}

.gif-result-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
