* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #000000 0%, #000000 50%, #000000 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #fff;
    overflow-x: hidden;
}

.background {
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
}

.background::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1;
}

.container {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: clamp(20px, 4vw, 40px);
    box-shadow: 
        0 25px 50px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    max-width: min(900px, 90vw);
    width: 100%;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
    z-index: 2;
    animation: fadeIn 0.6s ease-out forwards;
}

.container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(120, 119, 198, 0.15) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    animation: pulse 8s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.1); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

h1 {
    background: linear-gradient(135deg, #ffffff 0%, #ffffff 50%, #ffffff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: clamp(1.8em, 5vw, 2.8em);
    margin-bottom: 20px;
    font-weight: 800;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    gap: 15px;
    flex-wrap: wrap;
}

.scoreboard {
    display: flex;
    gap: 8px;
    align-items: center;
}

.scoreboard div {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    color: #fff;
    padding: 12px 18px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 18px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    min-width: 80px;
    position: relative;
    overflow: hidden;
}

.scoreboard div::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #118ab2, #06d6a0);
}

.buttons #startBtn{
    margin-left: 6px;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #118ab2 0%, #06d6a0 100%);
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(6, 214, 160, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.buttons #restartBtn{
    margin-left: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #ff6a00 0%, #d6a206 100%);
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(6, 214, 160, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.buttons #resetBtn{
    margin-left: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #ff0000 0%, #ff0000 100%);
    color: #ffffff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 5px 15px rgba(6, 214, 160, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.buttons button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 20px rgba(6, 214, 160, 0.5);
}

.buttons button:active {
    transform: translateY(0) scale(0.98);
}

.board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    padding: 12px;
    max-width: min(800px, 90vw);
    margin: 0 auto;
}

.card {
    position: relative;
    padding-top: 100%;
    cursor: pointer;
    perspective: 800px;
    border-radius: 18px;
    transition: all 0.3s ease;
}

.card:hover {
    transform: scale(1.05);
}

.card .inner {
    position: absolute;
    inset: 0;
    transition: transform 0.5s;
    transform-style: preserve-3d;
    border-radius: 16px;
}

.card.flipped .inner {
    transform: rotateY(180deg);
}

.card .front,
.card .back {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    backface-visibility: hidden;
    font-size: 1.5rem;
    font-weight: 700;
    box-shadow: 
        0 6px 20px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.15);
}

.card .front {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.card .back {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    transform: rotateY(180deg);
}

.card.matched .inner {
    box-shadow: 0 0 30px rgba(6, 214, 160, 0.6);
    outline: 4px solid rgba(78, 205, 196, 0.3);
    animation: correctPulse 0.6s ease-in-out;
}

.card.mismatch {
    animation: shake 0.5s ease-in-out;
}

.card.mismatch .back {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e8e 100%);
}

@keyframes correctPulse {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.1); }
    100% { transform: rotateY(180deg) scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.overlay {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 30px 40px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(20px);
    color: #fff;
    font-size: clamp(1.5em, 4vw, 2.2em);
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    text-align: center;
    font-weight: 700;
}

.overlay.visible {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

.overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, #ff6b6b, #ffd166, #06d6a0);
}

@media (max-width: 800px) {
    .board {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .controls {
        justify-content: center;
        gap: 12px;
    }
    
    .scoreboard {
        justify-content: center;
        width: 100%;
    }
    
    .buttons {
        display: flex;
        gap: 8px;
        justify-content: center;
        width: 100%;
    }
    
    .buttons button {
        margin-left: 0;
        flex: 1;
        min-width: 120px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px 15px;
        border-radius: 20px;
    }
    
    .board {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .scoreboard {
        gap: 10px;
    }
    
    .scoreboard div {
        padding: 10px 14px;
        min-width: 70px;
        font-size: 0.9em;
    }
    
    .buttons button {
        padding: 10px 15px;
        font-size: 0.9em;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px 12px;
        border-radius: 16px;
    }
    
    .board {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 8px;
    }
    
    .card .front,
    .card .back {
        font-size: 1.2rem;
    }
    
    .scoreboard {
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }
    
    .scoreboard div {
        width: 100%;
        text-align: center;
    }
    
    .buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .buttons button {
        width: 100%;
    }
    
    .overlay {
        padding: 20px 25px;
        font-size: 1.3em;
    }
}