* {
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: "Chalkboard SE","Comic Sans MS", cursive, sans-serif;
}

body {
    background-color: #f0f8ff;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

/* Animal Selection Banner Styles */
.animal-selection-banner {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f0f8ff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.selection-container {
    width: 95%;
    max-width: 800px;
    padding: clamp(15px, 3vw, 30px);
    background-color: #ffffff;
    border-radius: clamp(10px, 2vw, 20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.selection-container h2 {
    text-align: center;
    color: #4ecdc4;
    margin-bottom: clamp(10px, 2vh, 15px);
    font-size: clamp(1.4rem, 4vw, 2rem);
}

.selection-container p {
    text-align: center;
    color: #4d4d4d;
    margin-bottom: clamp(15px, 3vh, 25px);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
}

.animal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: clamp(8px, 2vw, 15px);
    margin-bottom: clamp(20px, 4vh, 30px);
}

.animal-option {
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffcc5c;
    border-radius: clamp(8px, 1.5vw, 12px);
    font-size: clamp(2rem, 5vw, 3rem);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    user-select: none;
}

.animal-option:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.animal-option.selected {
    background-color: #88d8b0;
    box-shadow: 0 0 15px rgba(136, 216, 176, 0.6);
    transform: scale(1.05);
}

.selection-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    position: sticky;
    bottom: 0;
    background-color: white;
    padding: 15px 0;
    border-top: 1px solid #eee;
}

.selected-count {
    color: #4d4d4d;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

.start-game-btn {
    background-color: #4ecdc4;
    color: white;
    border: none;
    border-radius: clamp(6px, 1.5vw, 10px);
    padding: clamp(8px, 2vw, 12px) clamp(15px, 3vw, 25px);
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.start-game-btn:hover:not([disabled]) {
    background-color: #36b5ac;
    transform: scale(1.05);
}

.start-game-btn:active:not([disabled]) {
    transform: scale(0.98);
}

.start-game-btn[disabled] {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

@media screen and (max-width: 600px) {
    .animal-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    }
}

@media screen and (max-width: 400px) {
    .animal-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }
    
    .selection-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .start-game-btn {
        width: 100%;
    }
}

.container {
    width: 95%;
    max-width: 800px;
    padding: clamp(10px, 3vw, 20px);
    background-color: #ffffff;
    border-radius: clamp(10px, 2vw, 20px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

h1 {
    text-align: center;
    color: #ff6b6b;
    margin-bottom: clamp(10px, 3vh, 20px);
    font-size: clamp(1.8rem, 5vw, 2.5rem);
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(10px, 3vh, 20px);
    font-size: clamp(1rem, 3vw, 1.5rem);
}

.moves {
    color: #4d4d4d;
}

#restart {
    background-color: #4ecdc4;
    color: white;
    border: none;
    border-radius: clamp(6px, 1.5vw, 10px);
    padding: clamp(6px, 1.5vw, 10px) clamp(10px, 2vw, 20px);
    font-size: clamp(0.9rem, 2.5vw, 1.2rem);
    cursor: pointer;
    transition: background-color 0.3s;
}

#restart:hover {
    background-color: #36b5ac;
}

.game-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: clamp(8px, 2vw, 15px);
    perspective: 1000px;
}

.card {
    aspect-ratio: 1 / 1;
    width: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    cursor: pointer;
    border-radius: clamp(8px, 2vw, 15px);
}

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: clamp(8px, 2vw, 15px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.card-front {
    background-color: #ffcc5c;
    transform: rotateY(180deg);
    font-size: clamp(3rem, 5vw, 6rem);
    color: #333;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
}

.card-back {
    background-color: #ff6b6b;
    background-image: linear-gradient(45deg, #ff6b6b 25%, #ff8e8e 25%, #ff8e8e 50%, #ff6b6b 50%, #ff6b6b 75%, #ff8e8e 75%, #ff8e8e);
    background-size: clamp(20px, 5vw, 40px) clamp(20px, 5vw, 40px);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.card-number {
    position: absolute;
    font-size: clamp(3rem, 4vw, 5rem);
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Hide the number when card is flipped */
.card.flipped .card-number {
    display: none;
}

.matched {
    background-color: #88d8b0;
}

.card-matched {
    animation: celebrate 0.8s ease-in-out;
    box-shadow: 0 0 20px rgba(136, 216, 176, 0.8);
    z-index: 10;
}

@keyframes celebrate {
    0% {
        transform: rotateY(180deg) scale(1);
    }
    25% {
        transform: rotateY(180deg) scale(1.1);
    }
    50% {
        transform: rotateY(180deg) scale(1);
    }
    75% {
        transform: rotateY(180deg) scale(1.05);
    }
    100% {
        transform: rotateY(180deg) scale(1);
    }
}

/* Celebration effect styles - simplified approach */
.celebrating {
    animation: celebrate-glow 1.5s ease-in-out;
    position: relative;
    z-index: 30;
}

.celebrating::before {
    content: '';
    position: absolute;
    top: clamp(-10px, -3vw, -20px);
    left: clamp(-10px, -3vw, -20px);
    right: clamp(-10px, -3vw, -20px);
    bottom: clamp(-10px, -3vw, -20px);
    border-radius: clamp(10px, 3vw, 20px);
    background: radial-gradient(circle, rgba(255,215,0,0.8) 0%, rgba(255,215,0,0) 70%);
    z-index: -1;
    animation: celebrate-pulse 1.5s ease-in-out;
}

.celebrating::after {
    content: '✨';
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: clamp(1.2rem, 4vw, 2rem);
    transform: translate(-50%, -50%);
    z-index: 40;
    animation: celebrate-sparkle 1.5s ease-in-out;
}

@keyframes celebrate-glow {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 215, 0, 0); }
    50% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.8); }
}

@keyframes celebrate-pulse {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

@keyframes celebrate-sparkle {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(0deg); }
    25% { opacity: 1; }
    50% { transform: translate(-50%, -50%) scale(1.5) rotate(180deg); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) rotate(360deg); }
}

/* Responsive breakpoints */
@media screen and (max-width: 1024px) {
    .container {
        width: 90%;
    }
}

@media screen and (max-width: 768px) {
    .container {
        width: 95%;
    }
}

@media screen and (max-width: 600px) {
    .game-container {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media screen and (max-width: 480px) {
    .game-info {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    #restart {
        width: 100%;
        max-width: 200px;
    }
}

@media screen and (max-width: 320px) {
    .game-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Completion message styles */
.completion-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    overflow: hidden;
}

.confetti-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1001;
}

.completion-message.show {
    opacity: 1;
    visibility: visible;
}

.message-content {
    background-color: white;
    padding: clamp(20px, 5vw, 40px);
    border-radius: clamp(10px, 2vw, 20px);
    text-align: center;
    max-width: 90%;
    width: clamp(280px, 80%, 500px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    transform: scale(0.8);
    transition: transform 0.3s ease;
    animation: message-pop 0.5s forwards;
}

@keyframes message-pop {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

.message-content h2 {
    color: #ff6b6b;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    margin-bottom: clamp(10px, 2vh, 20px);
}

.message-content p {
    color: #4d4d4d;
    font-size: clamp(1rem, 3vw, 1.3rem);
    margin-bottom: clamp(20px, 4vh, 30px);
}

.play-again-btn {
    background-color: #4ecdc4;
    color: white;
    border: none;
    border-radius: clamp(6px, 1.5vw, 10px);
    padding: clamp(8px, 2vw, 15px) clamp(15px, 3vw, 30px);
    font-size: clamp(1rem, 3vw, 1.2rem);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.play-again-btn:hover {
    background-color: #36b5ac;
    transform: scale(1.05);
}

.play-again-btn:active {
    transform: scale(0.98);
}
