body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100vh;
    margin: 0;
}

.game-container {
    background: #2d2d2d;
    border-radius: 10px;
    padding: 30px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 800px;
}

h1 {
    color: #6f4c9c;
    text-align: center;
    margin-bottom: 30px;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat {
    background: #3d3d3d;
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1.1em;
}

.stat-value {
    font-weight: bold;
    color: #6f4c9c;
}

.grid {
    display: grid;
    gap: 15px;
    margin-bottom: 20px;
    grid-template-columns: repeat(6, 1fr);
}

.card {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    transform-style: preserve-3d;
    z-index: 1;
    overflow: hidden;
}

.card.match, .card.mismatch {
    z-index: 2;
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
}

.card-front {
    background: #4a4a4a;
    color: #4a4a4a;
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.8em;
    backface-visibility: hidden;
    border-radius: 8px;
    padding: 3px;
    box-sizing: border-box;
}

.card-back {
    background: #6f4c9c;
    color: white;
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8em;
    backface-visibility: hidden;
    transform: rotateY(180deg);
    border-radius: 8px;
    padding: 3px;
    box-sizing: border-box;
}

.card-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 8px;
    z-index: -1;
    transition: background 0.3s;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

.card.match .card-bg {
    background: #4caf50;
}

.card.mismatch .card-bg {
    background: #f44336;
}

.card:hover:not(.flipped):not(.match) {
    transform: translateY(-5px);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.4);
}

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

button {
    background: #6f4c9c;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background 0.2s;
}

button:hover {
    background: #5a3a7c;
}

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

.difficulty button {
    background: #3d3d3d;
    color: #fff;
}

.difficulty button.active {
    background: #6f4c9c;
}

.message {
    text-align: center;
    font-size: 1.5em;
    margin: 20px 0;
    color: #4caf50;
}

.message.lose {
    color: #f44336;
}

.high-scores {
    margin-top: 20px;
    text-align: center;
    background: #3d3d3d;
    padding: 15px;
    border-radius: 5px;
}

.high-scores h3 {
    margin-top: 0;
    color: #6f4c9c;
}

.high-scores-list {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

.score-item {
    background: #2d2d2d;
    padding: 5px 15px;
    border-radius: 5px;
}

@media (max-width: 600px) {
    .grid {
        gap: 10px;
        grid-template-columns: repeat(4, 1fr);
    }

    .card {
        width: 60px;
        height: 60px;
        font-size: 2em;
    }
}