/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
    transition: all 0.5s ease;
}

/* Theme variations */
body.theme-ocean {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.theme-sunset {
    background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 50%, #fecfef 100%);
}

body.theme-forest {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

body.theme-space {
    background: linear-gradient(135deg, #0c0c0c 0%, #1a1a2e 50%, #16213e 100%);
    color: #fff;
}

body.theme-neon {
    background: linear-gradient(135deg, #ff006e 0%, #8338ec 50%, #3a86ff 100%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Header styles */
.game-header {
    text-align: center;
    margin-bottom: 30px;
    animation: fadeInDown 0.8s ease-out;
}

.game-header h1 {
    font-size: 3rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.subtitle {
    font-size: 1.2rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 300;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Stats section */
.game-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

.stat-item {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 140px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    font-size: 2rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.stat-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    line-height: 1;
}

/* Game controls */
.game-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    animation: fadeInUp 0.8s ease-out 0.4s both;
}

.btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.6);
}

.btn-secondary {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    box-shadow: 0 4px 15px rgba(116, 185, 255, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(116, 185, 255, 0.6);
}

.btn-accent {
    background: linear-gradient(135deg, #a8edea, #fed6e3);
    color: #333;
    box-shadow: 0 4px 15px rgba(168, 237, 234, 0.4);
}

.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(168, 237, 234, 0.6);
}

.btn-sound {
    background: linear-gradient(135deg, #ffecd2, #fcb69f);
    color: #333;
    box-shadow: 0 4px 15px rgba(255, 236, 210, 0.4);
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 10px 15px;
}

.btn-sound:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 236, 210, 0.6);
}

.btn-icon {
    font-size: 1.1rem;
}

/* Game board */
.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 500px;
    width: 100%;
    margin-bottom: 30px;
    animation: fadeInUp 0.8s ease-out 0.6s both;
}

.card {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    color: white;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.1);
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card:hover::before {
    opacity: 1;
}

.card:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.card.flip {
    background: linear-gradient(135deg, #fff, #f8f9fa);
    color: #333;
    transform: rotateY(180deg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.card.matched {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: white;
    cursor: default;
    transform: scale(0.95);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.4);
    animation: matchPulse 0.6s ease-out;
}

.card.matched:hover {
    transform: scale(0.95);
    box-shadow: 0 4px 20px rgba(0, 184, 148, 0.4);
}

.card.disabled {
    pointer-events: none;
    opacity: 0.7;
}

/* Game message */
.game-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 30px 40px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.game-message.show {
    opacity: 1;
    visibility: visible;
    animation: messagePop 0.5s ease-out;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes matchPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(0.95);
    }
}

@keyframes messagePop {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes cardFlip {
    0% {
        transform: rotateY(0deg);
    }

    50% {
        transform: rotateY(90deg);
    }

    100% {
        transform: rotateY(180deg);
    }
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .game-header h1 {
        font-size: 2.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .game-stats {
        flex-direction: column;
        gap: 15px;
        width: 100%;
        max-width: 300px;
    }

    .stat-item {
        min-width: auto;
        padding: 15px;
    }

    .game-controls {
        flex-direction: column;
        width: 100%;
        max-width: 300px;
    }

    .btn {
        justify-content: center;
        padding: 15px 24px;
    }

    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 10px;
        max-width: 350px;
    }

    .card {
        font-size: 2rem;
        border-radius: 15px;
    }

    .game-message {
        margin: 0 20px;
        padding: 25px 30px;
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    .game-header h1 {
        font-size: 2rem;
    }

    .game-board {
        max-width: 280px;
        gap: 8px;
    }

    .card {
        font-size: 1.8rem;
        border-radius: 12px;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Particle effects */
#particles-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999;
}

.particle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 2s ease-out forwards;
}

@keyframes particleFloat {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }

    100% {
        opacity: 0;
        transform: translateY(-100px) scale(0);
    }
}

/* Sound controls */
.sound-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

/* Difficulty indicators */
.difficulty-easy {
    --card-size: 1fr;
    --grid-cols: 4;
}

.difficulty-medium {
    --card-size: 0.8fr;
    --grid-cols: 5;
}

.difficulty-hard {
    --card-size: 0.7fr;
    --grid-cols: 6;
}

.game-board.difficulty-easy {
    grid-template-columns: repeat(4, 1fr);
}

.game-board.difficulty-medium {
    grid-template-columns: repeat(5, 1fr);
    max-width: 600px;
}

.game-board.difficulty-hard {
    grid-template-columns: repeat(6, 1fr);
    max-width: 700px;
}

/* Special card effects */
.card.special {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    animation: specialGlow 2s ease-in-out infinite alternate;
}

@keyframes specialGlow {
    0% {
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    }

    100% {
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
}

/* Theme-specific card styles */
body.theme-space .card {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    border: 1px solid #0f3460;
}

body.theme-space .card.flip {
    background: linear-gradient(135deg, #e94560, #f27121);
    color: white;
}

body.theme-neon .card {
    background: linear-gradient(135deg, #ff006e, #8338ec);
    border: 2px solid #3a86ff;
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.3);
}

body.theme-forest .card {
    background: linear-gradient(135deg, #11998e, #38ef7d);
}

body.theme-sunset .card {
    background: linear-gradient(135deg, #ff9a9e, #fecfef);
    color: #333;
}

/* Combo effects */
.combo-effect {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: comboPop 0.6s ease-out;
    pointer-events: none;
    z-index: 100;
}

@keyframes comboPop {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.5);
    }

    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.2);
    }

    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}