/* Variabel CSS untuk warna dan ukuran */
:root {
    --primary-color: #6a11cb;
    --secondary-color: #2575fc;
    --accent-color: #ff6b6b;
    --success-color: #4CAF50;
    --text-color: #333;
    --light-text: #fff;
    --card-bg: #fff;
    --card-back: #6a11cb;
    --shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
    --glow: 0 0 20px rgba(255, 215, 0, 0.6);
    --card-radius: 12px;
}

/* Reset dan base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    position: relative;
    overflow-x: hidden;
}

/* Efek latar belakang */
body::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200"><rect fill="none" width="200" height="200"/><path fill="rgba(255,255,255,0.05)" d="M100,0c27.6,0,50,22.4,50,50s-22.4,50-50,50s-50-22.4-50-50S72.4,0,100,0z"/></svg>');
    background-size: 30px;
    opacity: 0.3;
    z-index: -1;
}

/* Header styles */
header {
    margin-bottom: 25px;
    text-align: center;
    position: relative;
    padding: 10px 0;
}

h1 {
    color: var(--light-text);
    font-size: 2.5rem;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    display: inline-block;
}

h1::after {
    content: "";
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 4px;
    background: linear-gradient(to right, transparent, var(--accent-color), transparent);
    border-radius: 2px;
}

/* Info bar styles */
.info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin-bottom: 25px;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 15px 25px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(5px);
    animation: slideDown 0.5s ease;
}

.info-bar div {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-bar i {
    color: var(--primary-color);
    font-size: 1.2rem;
}

/* Cards grid styles */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
    max-width: 600px;
    margin-bottom: 25px;
    animation: fadeIn 0.8s ease;
}

/* Kartu styles */
.card {
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: var(--shadow);
    border-radius: var(--card-radius);
}

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

.card.matched .card-inner {
    animation: pulse 1s ease;
}

.card.matched .card-front {
    background: linear-gradient(135deg, var(--success-color), #3d8b40);
    box-shadow: var(--glow);
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--card-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: var(--shadow);
}

.card-front {
    background: linear-gradient(135deg, var(--card-back), #7a3cd8);
    color: var(--light-text);
    font-size: 1.8rem;
    font-weight: bold;
}

.card-front::before {
    content: "?";
    animation: pulse 2s infinite;
}

.card-back {
    background-color: var(--card-bg);
    transform: rotateY(180deg);
    font-size: 2rem;
    transition: all 0.3s ease;
}

.card.flipped .card-back {
    animation: popIn 0.5s ease;
}

/* Tombol restart styles */
.restart-btn {
    background: linear-gradient(to right, var(--accent-color), #ff8e8e);
    color: var(--light-text);
    border: none;
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
}

.restart-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.restart-btn:active {
    transform: translateY(0);
}

/* Pesan kemenangan styles */
.win-message {
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
    animation: zoomIn 0.5s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.win-message h2 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 2.2rem;
}

.win-message p {
    font-weight: 500;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

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

.stat-item {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    min-width: 100px;
}

.hidden {
    display: none;
}

/* Animasi */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes popIn {
    0% { transform: rotateY(180deg) scale(0.8); opacity: 0.7; }
    100% { transform: rotateY(180deg) scale(1); opacity: 1; }
}

@keyframes confetti {
    0% { transform: translateY(0) rotate(0); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Responsive design */
@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }
    
    .info-bar {
        padding: 12px 20px;
        font-size: 0.9rem;
    }
    
    .cards-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .card-front {
        font-size: 1.5rem;
    }
    
    .card-back {
        font-size: 1.7rem;
    }
    
    .restart-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    .win-message {
        padding: 20px;
    }
    
    .win-message h2 {
        font-size: 1.8rem;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
}

@media (min-width: 768px) {
    .cards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
    
    h1 {
        font-size: 3rem;
    }
    
    .card-back {
        font-size: 2.5rem;
    }
}

@media (min-width: 1024px) {
    .cards-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 15px;
    }
}

/* Prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
    .card-inner, .card, .restart-btn, .win-message, .info-bar {
        transition: none;
        animation: none;
    }
}

/* Efek confetti untuk kemenangan */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background-color: #f00;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
}
