:root {
    --card-size: 100px;
    --card-back-color: #2a3a4b;
    --card-front-color: #3498db;
    --matched-color: #2ecc71;
    --background-color: #f0f0f0;
    --font-color: #333;
}

body {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: sans-serif;
    background: radial-gradient(circle, #f0f0f0 0%, #e0e0e0 100%);
    color: var(--font-color);
}

h1 {
    background: linear-gradient(90deg, #2c3e50 0%, #34495e 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
    animation: fadeIn 1s ease-in-out;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.controls input {
    padding: 10px;
    font-size: 1.1em;
    border-radius: 8px;
    border: 2px solid transparent;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background: linear-gradient(135deg, #ecf0f1 0%, #ffffff 100%);
    transition: all 0.3s ease;
}

.controls input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.controls button {
    padding: 12px 24px;
    font-size: 1.1em;
    border-radius: 8px;
    border: none;
    color: white;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.controls button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

.controls button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* keyframes for a fade-in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.controls button:hover {
    background-color: #2980b9;
}

#game-board {
    display: grid;
    grid-gap: 10px;
    perspective: 1000px;
}

.card {
    width: var(--card-size);
    height: var(--card-size);
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s ease-in-out, box-shadow 0.3s ease;
    cursor: pointer;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.card.flip {
    transform: rotateY(180deg);
}

.card.matched {
    transform: rotateY(180deg);
    cursor: default;
    opacity: 1;
}

.card-front, .card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    color: white;
}

.card-back {
    background-color: var(--card-back-color);
    background-image: repeating-linear-gradient(-45deg,
        rgba(255, 255, 255, 0.05) 0px,
        rgba(255, 255, 255, 0.05) 2px,
        transparent 2px,
        transparent 4px);
    background-size: 8px 8px;
    border: 2px solid #2c3e50;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: rotateY(0deg);
}

.card-front {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    border: 2px solid #3498db;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    transform: rotateY(180deg);
}

.card.matched .card-front {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    border-color: #2ecc71;
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}

#game-over-message {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 10;
    opacity: 0;
    animation: bounceIn 0.8s forwards ease-out;
}

#game-over-message.hidden {
    display: none;
}

#restartButton {
    padding: 12px 24px;
    font-size: 1.1em;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    color: white;
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#restartButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* keyframes for the new bounce-in animation */
@keyframes bounceIn {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
    80% {
        transform: translate(-50%, -50%) scale(0.95);
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}