:root {
    --bg-gradient-start: #be185d;
    /* Pink 700 */
    --bg-gradient-end: #881337;
    /* Pink 900 */
    --card-back: #10b981;
    /* Emerald 500 */
    --card-face: #fde047;
    /* Yellow 300 */
    --text-color: #ffffff;
    --text-card: #000000;

    --card-size: 80px;
    --gap-size: 15px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Baloo Thambi 2', 'Outfit', sans-serif;
    user-select: none;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start), var(--bg-gradient-end));
    min-height: 100vh;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    /* align-items: center; Remove center align to let it flow from top */
    padding-top: 40px;
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header */
.game-header {
    margin-bottom: 30px;
    text-align: center;
}

.game-title {
    font-size: 2.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Controls */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    align-items: center;
    margin-bottom: 40px;
    width: 100%;
}

.difficulty-toggles {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.diff-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.diff-btn.active {
    background: #10b981;
    /* Green active */
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stats-panel {
    display: flex;
    gap: 15px;
    align-items: center;
}

.stat-item {
    background: white;
    color: #333;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.timer-box {
    color: #dc2626;
}

/* Red text for timer */

.reset-btn {
    background: white;
    color: #333;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: transform 0.2s;
}

.reset-btn:active {
    transform: scale(0.95);
}

/* Game Grid */
.game-board-wrapper {
    perspective: 1000px;
    /* For 3D flip */
}

.game-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--gap-size);
    /* margin: 0 auto; */
}

/* Cards */
.card {
    width: var(--card-size);
    height: var(--card-size);
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    cursor: pointer;
}

.card:active {
    transform: scale(0.95);
}

.card.flipped {
    transform: rotateY(180deg);
    cursor: default;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-size: 1.5rem;
    font-weight: bold;
}

.card-front {
    background-color: var(--card-back);
    color: white;
    transform: rotateY(0deg);
}

.card-back {
    background-color: var(--card-face);
    color: var(--text-card);
    transform: rotateY(180deg);
    padding: 5px;
    /* Prevent text touching edges */
    font-size: 1.2rem;
    /* bit smaller for text */
}

.card-front i {
    font-size: 1.5rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    color: #333;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    animation: popIn 0.3s ease;
    max-width: 90%;
    width: 350px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.star-burst {
    font-size: 4rem;
    margin-bottom: 20px;
    animation: spin 20s linear infinite;
}

.modal h2 {
    color: var(--bg-gradient-start);
    margin-bottom: 10px;
}

.final-stats {
    margin: 20px 0;
    font-size: 1.1rem;
}

.primary-btn {
    background: var(--bg-gradient-start);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
}

/* Animations */
@keyframes popIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .game-grid {
        gap: 10px;
    }

    .card {
        width: 70px;
        height: 70px;
    }

    .game-title {
        font-size: 1.8rem;
    }
}