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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 100px 20px 20px;
}

.game-container {
    max-width: 700px;
    width: 100%;
    margin: 0 auto;
}

/* Top Panel */
.top-panel {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    justify-content: center;
    flex-wrap: wrap;
}

.stat-box {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 12px 20px;
    border-radius: 12px;
    text-align: center;
    border: 2px solid rgba(255, 255, 255, 0.3);
    min-width: 80px;
}

.stat-label {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 900;
    color: #fff;
}

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

.card {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    transition: all 0.3s;
    position: relative;
    transform-style: preserve-3d;
}

.game-board.easy .card {
    font-size: 3rem;
}

.game-board.medium .card {
    font-size: 2.2rem;
}

.game-board.hard .card {
    font-size: 2.5rem;
}

.card:hover {
    transform: scale(1.05);
    border-color: rgba(255, 255, 255, 0.8);
}

.card.flipped {
    background: #fff;
    border-color: #667eea;
}

.card.matched {
    background: rgba(67, 233, 123, 0.3);
    border-color: #43e97b;
    cursor: default;
    animation: matchPulse 0.5s;
}

@keyframes matchPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.card.wrong {
    animation: shake 0.4s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.overlay.show {
    display: flex;
}

.menu-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    padding: 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.menu-card h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    color: #fff;
}

.menu-card p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 30px;
    line-height: 1.6;
}

/* Difficulty Select */
.difficulty-select {
    margin: 20px 0;
}

.diff-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    width: 100%;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    padding: 15px 20px;
    border-radius: 12px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: left;
}

.diff-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateX(5px);
}

.diff-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: #43e97b;
    box-shadow: 0 0 20px rgba(67, 233, 123, 0.3);
}

.diff-icon {
    font-size: 2rem;
}

.diff-name {
    flex: 1;
    font-weight: 700;
    font-size: 1.1rem;
}

.diff-desc {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
}

/* Primary Button */
.btn-primary {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
    border: none;
    color: #000;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-top: 20px;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(67, 233, 123, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
    margin-top: 10px;
}

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

/* Win Stats */
.win-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
}

.win-stat {
    background: rgba(255, 255, 255, 0.2);
    padding: 20px;
    border-radius: 12px;
    flex: 1;
}

.win-label {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
}

.win-value {
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
}

/* Mobile */
@media (max-width: 768px) {
    .game-board.easy {
        grid-template-columns: repeat(4, 70px);
        grid-template-rows: repeat(4, 70px);
    }
    
    .game-board.medium {
        grid-template-columns: repeat(6, 50px);
        grid-template-rows: repeat(5, 50px);
    }
    
    .game-board.hard {
        grid-template-columns: repeat(6, 50px);
        grid-template-rows: repeat(6, 50px);
    }
    
    .game-board.easy .card {
        font-size: 2.5rem;
    }
    
    .game-board.medium .card {
        font-size: 1.8rem;
    }
    
    .game-board.hard .card {
        font-size: 1.8rem;
    }
    
    .game-board {
        gap: 6px;
    }
    
    .menu-card {
        padding: 30px 20px;
    }
    
    .stat-box {
        padding: 10px 15px;
        min-width: 70px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .win-stats {
        flex-direction: column;
        gap: 10px;
    }
}

/* Level Grid */
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
}

.level-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 15px 10px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.level-btn.unlocked:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.05);
}

.level-btn.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

.level-btn.active {
    background: rgba(67,233,123,0.3);
    border-color: #43e97b;
    box-shadow: 0 0 15px rgba(67,233,123,0.5);
}

.level-number {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 5px;
}

.level-name {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 3px;
}

.level-info {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.6);
}

/* Countdown Overlay */
.countdown-card {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(20px);
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 30px;
    padding: 60px;
    text-align: center;
}

.countdown-number {
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(255,255,255,0.8);
    animation: countdownPulse 1s infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Time Warning (Red Pulse) */
body.time-warning {
    animation: timeWarning 1s infinite;
}

@keyframes timeWarning {
    0%, 100% { 
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    50% { 
        background: linear-gradient(135deg, #ff6b6b 0%, #c92a2a 100%);
    }
}

/* Stars */
.stars {
    display: flex;
    gap: 10px;
    justify-content: center;
    font-size: 3rem;
    margin: 20px 0;
}

.star {
    animation: starPop 0.5s ease-out;
}

.star:nth-child(1) { animation-delay: 0.1s; }
.star:nth-child(2) { animation-delay: 0.3s; }
.star:nth-child(3) { animation-delay: 0.5s; }

@keyframes starPop {
    0% { transform: scale(0) rotate(0deg); }
    50% { transform: scale(1.3) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}
