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

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    padding: 30px;
    max-width: 800px;
    width: 90%;
}

.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.game-header h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-config {
    text-align: center;
    margin-bottom: 30px;
}

.game-config h2 {
    color: #2c3e50;
    font-size: 2rem;
    margin-bottom: 25px;
}

.config-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.config-btn {
    background: linear-gradient(135deg, #ecf0f1, #bdc3c7);
    border: 3px solid #bdc3c7;
    border-radius: 20px;
    padding: 20px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 1rem;
    text-align: center;
}

.config-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.config-btn.active {
    background: linear-gradient(135deg, #3498db, #2980b9);
    border-color: #2980b9;
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(52, 152, 219, 0.4);
}

.config-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 8px;
}

.config-details {
    font-size: 1rem;
    margin-bottom: 5px;
    opacity: 0.9;
}

.config-grid {
    font-size: 0.9rem;
    opacity: 0.8;
}

.start-button {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 1.4rem;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
    transition: all 0.3s ease;
}

.start-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(39, 174, 96, 0.6);
}

.start-button:active {
    transform: translateY(0);
}

.game-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.pairs-remaining {
    background: #e8f8f5;
    color: #27ae60;
    padding: 12px 20px;
    border-radius: 25px;
    border: 3px solid #27ae60;
    font-size: 1.2rem;
    font-weight: bold;
}

.players-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 20px;
}

.player {
    background: #ecf0f1;
    padding: 15px 20px;
    border-radius: 20px;
    border: 3px solid #bdc3c7;
    text-align: center;
    transition: all 0.3s ease;
    min-width: 120px;
}

.player.active {
    border-color: #3498db;
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.player-1.active {
    border-color: #e74c3c;
    background: linear-gradient(135deg, #ffebee, #ffcdd2);
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.player-2.active {
    border-color: #27ae60;
    background: linear-gradient(135deg, #e8f5e8, #c8e6c9);
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.player-name {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.player-score {
    font-size: 1.3rem;
    font-weight: bold;
    color: #34495e;
}

.current-player-indicator {
    flex: 1;
    text-align: center;
}

.current-player-text {
    background: linear-gradient(45deg, #ff6b6b, #ee5a6f);
    color: white;
    padding: 12px 25px;
    border-radius: 25px;
    font-size: 1.3rem;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(238, 90, 111, 0.4);
    animation: pulse 2s infinite;
}

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

.game-controls {
    text-align: center;
}

.reset-button {
    background: linear-gradient(45deg, #ff6b6b, #ee5a6f);
    color: white;
    border: none;
    padding: 12px 25px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(238, 90, 111, 0.4);
    transition: all 0.3s ease;
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(238, 90, 111, 0.6);
}

.reset-button:active {
    transform: translateY(0);
}

.game-board {
    display: grid;
    gap: 15px;
    margin-bottom: 30px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.game-board.grid-4x3 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
}

.game-board.grid-4x4 {
    grid-template-columns: repeat(4, 1fr);
    max-width: 600px;
}

.game-board.grid-5x4 {
    grid-template-columns: repeat(5, 1fr);
    max-width: 700px;
}

.game-board.grid-5x5 {
    grid-template-columns: repeat(5, 1fr);
    max-width: 700px;
}

.game-board.grid-6x5 {
    grid-template-columns: repeat(6, 1fr);
    max-width: 800px;
}

.card {
    aspect-ratio: 3/4;
    position: relative;
    cursor: pointer;
    perspective: 1000px;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s ease;
    transform-style: preserve-3d;
}

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

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

.card-back {
    background: #3498db;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: rotateY(0deg);
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: white;
}

.card.matched {
    opacity: 0.8;
    transform: scale(0.95);
}

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

.card:not(.matched):hover {
    transform: translateY(-5px);
    transition: transform 0.3s ease;
}

.message-area {
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-message {
    font-size: 1.5rem;
    font-weight: bold;
    padding: 15px 30px;
    border-radius: 25px;
    transition: all 0.5s ease;
}

.game-message.success {
    background: linear-gradient(45deg, #27ae60, #2ecc71);
    color: white;
    box-shadow: 0 4px 15px rgba(39, 174, 96, 0.4);
    animation: celebration 0.6s ease;
}

.game-message.match {
    background: linear-gradient(45deg, #f39c12, #e67e22);
    color: white;
    box-shadow: 0 4px 15px rgba(243, 156, 18, 0.4);
}

@keyframes celebration {
    0% { transform: scale(0.5) rotate(0deg); opacity: 0; }
    50% { transform: scale(1.1) rotate(5deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

@media (max-width: 768px) {
    .game-container {
        padding: 20px;
        width: 95%;
    }
    
    .game-header h1 {
        font-size: 2rem;
    }
    
    .game-config h2 {
        font-size: 1.5rem;
    }
    
    .config-options {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .config-btn {
        padding: 15px 10px;
    }
    
    .config-title {
        font-size: 1.1rem;
    }
    
    .start-button {
        font-size: 1.2rem;
        padding: 12px 30px;
    }
    
    .game-board {
        gap: 10px;
    }
    
    .game-board.grid-5x5,
    .game-board.grid-6x5 {
        grid-template-columns: repeat(4, 1fr);
        max-width: 600px;
    }
    
    .players-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .current-player-text {
        font-size: 1.1rem;
        padding: 10px 20px;
    }
    
    .player {
        min-width: auto;
        width: 100%;
        max-width: 200px;
        margin: 0 auto;
    }
    
    .game-status {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .reset-button {
        font-size: 1rem;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    .config-options {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .players-info {
        flex-direction: column;
        gap: 10px;
    }
    
    .game-board.grid-4x3,
    .game-board.grid-4x4,
    .game-board.grid-5x4,
    .game-board.grid-5x5,
    .game-board.grid-6x5 {
        grid-template-columns: repeat(3, 1fr);
        max-width: 500px;
    }
    
    .player-name {
        font-size: 1rem;
    }
    
    .player-score {
        font-size: 1.1rem;
    }
}