/* CSS Variables */
:root {
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  --accent-gradient: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  --card-bg: rgba(255, 255, 255, 0.05);
  --border-color: rgba(255, 255, 255, 0.1);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.8);
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-light: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.2);
  --shadow-heavy: 0 20px 40px rgba(0, 0, 0, 0.3);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: #0A0A23;
    color: #FFFFFF;
    margin: 0;
    min-height: 100vh;
    user-select: none;
}

/* Game Main */
.game-main {
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

/* Game Info */
.game-info {
    margin-bottom: 30px;
}

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

.score-box {
    background: linear-gradient(135deg, #003566, #001D3D);
    border: 2px solid #00B4DB;
    border-radius: 10px;
    padding: 15px 25px;
    min-width: 120px;
}

.score-label {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 5px;
}

.score-value {
    font-size: 2rem;
    font-weight: bold;
    color: #00B4DB;
}

.game-instructions {
    max-width: 400px;
    margin: 0 auto;
    opacity: 0.8;
    line-height: 1.5;
}

/* Game Board */
.game-board {
    background: #003566;
    border-radius: 15px;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    width: 400px;
    height: 400px;
    margin: 0 auto 30px;
    position: relative;
    border: 3px solid #00B4DB;
}

.grid-cell {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    position: relative;
    transition: all 0.15s ease-in-out;
}

.tile {
    position: absolute;
    width: calc(25% - 7.5px);
    height: calc(25% - 7.5px);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.15s ease-in-out;
    z-index: 10;
}

/* Tile Colors */
.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: 1.8rem; }
.tile-256 { background: #edcc61; color: #f9f6f2; font-size: 1.8rem; }
.tile-512 { background: #edc850; color: #f9f6f2; font-size: 1.8rem; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 1.5rem; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 1.5rem; box-shadow: 0 0 20px rgba(237, 194, 46, 0.5); }

.tile-4096 { background: #ff6b6b; color: #f9f6f2; font-size: 1.3rem; }
.tile-8192 { background: #ff5252; color: #f9f6f2; font-size: 1.3rem; }

/* Tile Animations */
.tile-new {
    animation: tileAppear 0.2s ease-in-out;
}

.tile-merged {
    animation: tileMerge 0.15s ease-in-out;
}

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

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

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.control-btn {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.control-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

/* Modals */
.game-over-modal, .win-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 35, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: linear-gradient(135deg, #003566, #001D3D);
    border: 2px solid #00B4DB;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #4CAF50;
}

.final-score {
    margin: 20px 0;
}

.final-score p {
    font-size: 1.2rem;
    margin: 10px 0;
    color: #00B4DB;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

.modal-buttons button {
    background: linear-gradient(45deg, #4CAF50, #45a049);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-buttons button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

/* Touch Controls Hint */
.touch-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 180, 219, 0.2);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Responsive design */
@media (max-width: 768px) {
    .game-main {
        padding: 15px;
    }
    
    .game-board {
        width: 320px;
        height: 320px;
        padding: 12px;
        gap: 8px;
    }
    
    .tile {
        font-size: 1.5rem;
        width: calc(25% - 6px);
        height: calc(25% - 6px);
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1.3rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 1.1rem;
    }
    
    .tile-4096, .tile-8192 {
        font-size: 1rem;
    }
    
    .score-container {
        gap: 15px;
    }
    
    .score-box {
        padding: 12px 20px;
        min-width: 100px;
    }
    
    .score-value {
        font-size: 1.5rem;
    }
    
    .game-instructions {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        width: 280px;
        height: 280px;
        padding: 10px;
        gap: 6px;
    }
    
    .tile {
        font-size: 1.2rem;
        width: calc(25% - 4.5px);
        height: calc(25% - 4.5px);
    }
    
    .tile-128, .tile-256, .tile-512 {
        font-size: 1rem;
    }
    
    .tile-1024, .tile-2048 {
        font-size: 0.9rem;
    }
    
    .tile-4096, .tile-8192 {
        font-size: 0.8rem;
    }
}