:root {
    --bg-color: #1a1a1a;
    --text-color: #4caf50;
    --card-bg: #fff;
    --card-back: #ffb300;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 100vh;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    padding: 1rem;
    position: relative;
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.back-btn {
    text-decoration: none;
    color: #fff;
    background-color: #ff9800;
    padding: 10px 20px;
    border-radius: 20px;
    font-weight: bold;
    box-shadow: 0 4px 0 #f57c00;
    transition: transform 0.1s, box-shadow 0.1s;
}

.back-btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #f57c00;
}

h1 {
    font-size: 2.2rem;
    color: var(--text-color);
    text-shadow: 2px 2px 0 #000;
}

.hud {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    font-weight: 900;
    background: rgba(255, 255, 255, 0.8);
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
}

.restart-btn {
    background: #ff5252;
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 15px;
    font-weight: bold;
    font-family: 'Outfit';
    cursor: pointer;
    box-shadow: 0 3px 0 #d32f2f;
}

.restart-btn:active {
    transform: translateY(3px);
    box-shadow: 0 0 0 #d32f2f;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 500px;
    perspective: 1000px;
}

.card {
    aspect-ratio: 1;
    background-color: transparent;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

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

.card.matched {
    transform: rotateY(180deg) scale(0.95);
    opacity: 0.8;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 3rem;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.card-front {
    background-color: var(--card-back);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,0.1) 10px, rgba(255,255,255,0.1) 20px);
}

.card-back {
    background-color: var(--card-bg);
    transform: rotateY(180deg);
}

.overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    backdrop-filter: blur(5px);
    border-radius: 20px;
}

.overlay h2 {
    font-size: 3rem;
    color: #4caf50;
    margin-bottom: 1rem;
    text-align: center;
}

.overlay p {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: #455a64;
    text-align: center;
}

.btn {
    background-color: #4caf50;
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 6px 0 #388e3c;
    transition: transform 0.1s, box-shadow 0.1s;
    font-family: 'Outfit', sans-serif;
}

.btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 #388e3c;
}

.hidden {
    display: none !important;
}

@media (max-width: 500px) {
    .card-face { font-size: 2rem; }
    h1 { font-size: 1.8rem; }
    .hud { font-size: 1.2rem; }
}
