:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #ec4899;
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.8);
    --card-face: #ffffff;
    --card-back: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    --text-color: #1e293b;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: #e2e8f0;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    min-height: 100vh;
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 30px;
    animation: fadeIn 0.5s ease-out;
}

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

header {
    text-align: center;
}

header h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 10px;
    color: var(--primary);
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Controls Section */
.controls {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    padding: 20px;
    border-radius: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.control-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

#game-mode, #grid-size {
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: white;
    color: #333;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    width: 100%;
}

label {
    font-weight: 600;
}

select {
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: white;
    color: #333;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    outline: none;
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    font-weight: 600;
}

.stat-item span {
    color: #fcd34d;
    font-size: 1.3rem;
}

.actions {
    display: flex;
    gap: 10px;
}

.btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--primary);
    color: white;
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

.btn.secondary {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn.secondary:hover {
    background: rgba(255,255,255,0.1);
}

/* Game Board */
.game-board {
    display: grid;
    gap: 10px;
    justify-content: center;
    perspective: 1000px;
    margin: 0 auto;
    width: 100%;
}

/* Card Styling */
.card {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.card.matched {
    animation: matchSuccess 0.5s ease-out forwards;
    pointer-events: none;
}

@keyframes matchSuccess {
    0% { transform: rotateY(180deg) scale(1); }
    50% { transform: rotateY(180deg) scale(1.2); }
    100% { transform: rotateY(180deg) scale(1); box-shadow: 0 0 20px #fcd34d; }
}

.card-face img {
    width: 90%;
    height: 90%;
    object-fit: contain;
    border-radius: 10px;
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 15px;
    font-size: 2.5rem;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05), 0 0 1px rgba(0,0,0,0.1);
    background: white;
}

.card-front {
    background: var(--card-face);
    color: var(--primary);
    transform: rotateY(180deg);
}

.card-back {
    background: var(--card-back);
    color: white;
}

.card-back::after {
    content: '?';
    font-size: 2rem;
    opacity: 0.5;
}

/* Win Message */
.win-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    color: #333;
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    z-index: 100;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

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

.win-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 90;
    animation: fadeInOverlay 0.5s ease-out;
}

@keyframes fadeInOverlay {
    from { opacity: 0; }
    to { opacity: 1; }
}

.hidden {
    display: none !important;
}

/* Print View Styles */
.print-view {
    display: none;
}

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: white;
        padding: 0;
    }

    .print-view {
        display: block;
        width: 100%;
        color: black;
    }

    .print-header {
        text-align: center;
        margin-bottom: 20px;
        page-break-before: auto;
    }

    .print-break {
        page-break-after: always;
        height: 0;
    }

    .print-grid {
        display: grid;
        grid-template-columns: repeat(6, 1fr);
        gap: 10px;
        padding: 20px;
    }

    .print-card {
        aspect-ratio: 1;
        border: 2px dashed #333;
        display: flex;
        justify-content: center;
        align-items: center;
        font-size: 2.5rem;
        font-weight: 800;
        border-radius: 10px;
        background: white;
    }

    .print-card-back {
        background: #f3f4f6;
        color: #d1d5db;
    }
}
