* {
    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;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.container {
    max-width: 400px;
    width: 90%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 20px;
}

h1 {
    color: #333;
    font-size: 24px;
    margin-bottom: 15px;
}

.score-board {
    display: flex;
    justify-content: space-between;
    background: #f0f0f0;
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    color: #555;
}

.grid-container {
    display: flex;
    justify-content: center;
}

.grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    background: #ddd;
    padding: 5px;
    border-radius: 10px;
    width: 100%;
    max-width: 320px;
}

.cell {
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    border: 2px solid transparent;
}

.cell:hover {
    transform: scale(1.05);
}

.cell.selected {
    border-color: #ffd700;
    transform: scale(1.1);
}

.cell.red { background: #ff6b6b; color: white; }
.cell.blue { background: #4ecdc4; color: white; }
.cell.green { background: #45b7d1; color: white; }
.cell.yellow { background: #f9ca24; color: white; }
.cell.purple { background: #a55eea; color: white; }
.cell.orange { background: #fd9644; color: white; }

.cell.matching {
    animation: match 0.5s ease-in-out;
}

@keyframes match {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); background: #ffd700; }
    100% { transform: scale(0); opacity: 0; }
}

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

.modal {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 300px;
    width: 90%;
}

.modal h2 {
    margin-bottom: 15px;
    color: #333;
}

.modal p {
    margin-bottom: 20px;
    font-size: 18px;
    color: #666;
}

button {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #5a6fd8;
}

.hidden {
    display: none;
}

@media (max-width: 480px) {
    .container {
        width: 95%;
        padding: 15px;
    }
    
    h1 {
        font-size: 20px;
    }
    
    .score-board {
        font-size: 14px;
        padding: 8px;
    }
    
    .cell {
        font-size: 16px;
    }
}