/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Fredoka One', 'Bungee', 'Kalam', 'Comic Sans MS', 'Arial Rounded MT', Arial, sans-serif;
    background: linear-gradient(135deg, #fffbea 0%, #ffeaa7 50%, #fff9c4 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* Decorative pattern overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(255, 152, 0, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 193, 7, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    max-width: 1200px;
    width: 100%;
    background: linear-gradient(135deg, #ffffff 0%, #fffef5 100%);
    border-radius: 25px;
    padding: 35px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
    border: 3px solid rgba(255, 193, 7, 0.3);
}

header {
    text-align: center;
    margin-bottom: 25px;
}

.header-decoration {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.decor-icon {
    font-size: 2em;
    animation: float 3s ease-in-out infinite;
    opacity: 0.8;
}

.decor-icon:nth-child(1) { animation-delay: 0s; }
.decor-icon:nth-child(2) { animation-delay: 0.5s; }
.decor-icon:nth-child(4) { animation-delay: 1s; }
.decor-icon:nth-child(5) { animation-delay: 1.5s; }

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

h1 {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff9800 50%, #ff5722 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.8em;
    margin: 0;
    text-shadow: none;
    font-weight: bold;
}

.subtitle {
    color: #666;
    font-size: 1.2em;
    margin-bottom: 20px;
}

/* Scoreboard */
#scoreboard {
    display: flex;
    justify-content: center;
    gap: 40px;
    background: linear-gradient(135deg, #fff9c4 0%, #ffe082 50%, #ffd54f 100%);
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 25px;
    box-shadow: 0 5px 15px rgba(255, 193, 7, 0.3);
    border: 2px solid rgba(255, 193, 7, 0.5);
    position: relative;
    overflow: hidden;
}

#scoreboard::before {
    content: '⭐🎉✨';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.5em;
    opacity: 0.3;
    animation: shine 2s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.6; }
}

.score-item {
    font-size: 1.4em;
    font-weight: bold;
    color: #ff6b00;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    position: relative;
    z-index: 1;
}

.label {
    margin-right: 5px;
}

/* Message Area */
#message-area {
    min-height: 40px;
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    color: #1976D2;
    margin-bottom: 20px;
}

/* Game Boards Container */
#game-boards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-bottom: 35px;
}

.board-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    padding: 25px;
    border-radius: 20px;
    border: 3px solid rgba(255, 193, 7, 0.3);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.board-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.board-title {
    text-align: center;
    background: linear-gradient(135deg, #1976D2 0%, #0288d1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.6em;
    margin-bottom: 20px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Board - contains cards */
.board {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 400px;
}

/* Card Styles */
.card {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin: 0;
    text-align: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    font-size: 1.1em;
    font-weight: 500;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    overflow-wrap: break-word;
    position: relative;
}

/* Word Card Styles with Large Emoji */
.word-card {
    flex-direction: column;
    background: linear-gradient(135deg, #ffeb3b 0%, #ff9800 100%);
    padding: 25px 20px;
    min-height: 120px;
}

.card-emoji {
    font-size: 5em;
    line-height: 1;
    margin-bottom: 10px;
    animation: pulse-emoji 2s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes pulse-emoji {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.card-word-text {
    font-size: 1.3em;
    font-weight: bold;
    color: #333;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
}

/* Sentence Card Styles */
.sentence-card {
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    color: white;
    font-size: 1.1em;
    padding: 18px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.card:hover {
    transform: scale(1.05) translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    border-color: rgba(255, 193, 7, 0.5);
}

.word-card:hover {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
    box-shadow: 0 8px 25px rgba(255, 152, 0, 0.4);
}

.sentence-card:hover {
    background: linear-gradient(135deg, #29b6f6 0%, #0288d1 100%);
    box-shadow: 0 8px 25px rgba(41, 182, 246, 0.4);
}

.card.selected {
    background: linear-gradient(135deg, #ffd700 0%, #ffc107 100%);
    border: 3px solid #ff9800;
    transform: scale(1.08) translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 193, 7, 0.6);
    animation: selected-glow 1.5s ease-in-out infinite;
}

@keyframes selected-glow {
    0%, 100% { box-shadow: 0 10px 30px rgba(255, 193, 7, 0.6); }
    50% { box-shadow: 0 10px 40px rgba(255, 193, 7, 0.9); }
}

.card.matched {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
    border: 3px solid #2e8b57;
    cursor: default;
    animation: match-celebration 0.6s ease-out;
}

@keyframes match-celebration {
    0% { transform: scale(1); }
    50% { transform: scale(1.1) rotate(2deg); }
    100% { transform: scale(1); }
}

.card.matched:hover {
    transform: scale(1);
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
}

.word-card.matched .card-emoji {
    animation: celebrate-emoji 0.6s ease-out;
}

@keyframes celebrate-emoji {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-10deg); }
    75% { transform: scale(1.2) rotate(10deg); }
}

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

.btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff9800 50%, #ff5722 100%);
    color: white;
    border: none;
    padding: 18px 35px;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 15px rgba(255, 107, 107, 0.4);
    font-family: 'Poppins', 'Comic Sans MS', 'Arial Rounded MT', Arial, sans-serif;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 10px 25px rgba(255, 107, 107, 0.6);
    background: linear-gradient(135deg, #ff5722 0%, #ff9800 50%, #ff6b6b 100%);
}

.btn:active {
    transform: translateY(0);
}

/* Success Popup Styles (for each correct match) */
.success-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.success-popup.hidden {
    display: none;
}

.success-popup-content {
    background: linear-gradient(135deg, #66bb6a 0%, #4caf50 100%);
    padding: 50px 40px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(76, 175, 80, 0.5);
    max-width: 400px;
    width: 90%;
    border: 4px solid #2e8b57;
    animation: successPopupBounce 0.5s ease-out;
    position: relative;
    overflow: hidden;
}

@keyframes successPopupBounce {
    0% {
        transform: scale(0.3) translateY(-100px);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) translateY(10px);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.success-popup-content::before {
    content: '✨🌟⭐';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.5em;
    opacity: 0.6;
    animation: float 2s ease-in-out infinite;
}

.success-emoji {
    font-size: 5em;
    margin-bottom: 15px;
    animation: celebrateEmoji 0.6s ease-out;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

@keyframes celebrateEmoji {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.3) rotate(-15deg); }
    75% { transform: scale(1.3) rotate(15deg); }
}

.success-title {
    color: white;
    font-size: 2.5em;
    margin-bottom: 15px;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    font-family: 'Fredoka One', cursive;
}

.success-message {
    color: white;
    font-size: 1.4em;
    margin-bottom: 25px;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    line-height: 1.4;
}

.btn-success {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    color: #2e8b57;
    border: 3px solid white;
    font-weight: bold;
    padding: 12px 30px;
    font-size: 1.1em;
}

.btn-success:hover {
    background: linear-gradient(135deg, #f5f5f5 0%, #ffffff 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 8px 20px rgba(255, 255, 255, 0.4);
}

/* Popup Styles */
.popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

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

.popup.hidden {
    display: none;
}

.popup-content {
    background: linear-gradient(135deg, #ffffff 0%, #fff9c4 100%);
    padding: 45px;
    border-radius: 25px;
    text-align: center;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.4);
    max-width: 450px;
    width: 90%;
    border: 3px solid rgba(255, 193, 7, 0.5);
    animation: popupSlide 0.4s ease-out;
    position: relative;
    overflow: hidden;
}

@keyframes popupSlide {
    from { 
        transform: translateY(-50px) scale(0.9);
        opacity: 0;
    }
    to { 
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.popup-content::before {
    content: '🎉✨🎊';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2em;
    opacity: 0.3;
    animation: float 2s ease-in-out infinite;
}

.popup-content h2 {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff9800 50%, #ff5722 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 2.2em;
    margin-bottom: 20px;
    font-weight: bold;
}

.popup-content p {
    font-size: 1.4em;
    color: #666;
    margin-bottom: 15px;
    font-weight: 500;
}

.popup-stats {
    margin: 25px 0;
    padding: 25px;
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    border-radius: 15px;
    border: 2px solid rgba(25, 118, 210, 0.3);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

.popup-stats p {
    font-size: 1.3em;
    margin: 12px 0;
    color: #1976D2;
    font-weight: bold;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-decoration {
        flex-wrap: wrap;
        gap: 10px;
    }

    .decor-icon {
        font-size: 1.5em;
    }

    h1 {
        font-size: 2.2em;
    }

    #game-boards {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .board-container {
        padding: 20px;
    }

    .board {
        min-height: 350px;
        gap: 15px;
    }

    .card {
        font-size: 1em;
        padding: 18px;
        min-height: 70px;
    }

    .word-card {
        min-height: 110px;
        padding: 20px 15px;
    }

    .card-emoji {
        font-size: 4em;
    }

    .card-word-text {
        font-size: 1.2em;
    }

    .sentence-card {
        padding: 16px;
        font-size: 1em;
    }

    .score-item {
        font-size: 1.2em;
    }

    #scoreboard {
        gap: 25px;
        padding: 18px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    .header-decoration {
        gap: 8px;
    }

    .decor-icon {
        font-size: 1.2em;
    }

    h1 {
        font-size: 1.8em;
    }

    .subtitle {
        font-size: 1em;
    }

    .board-title {
        font-size: 1.3em;
    }

    .board-container {
        padding: 15px;
    }

    .card {
        font-size: 0.95em;
        padding: 15px;
        min-height: 65px;
    }

    .word-card {
        min-height: 100px;
        padding: 18px 12px;
    }

    .card-emoji {
        font-size: 3.5em;
        margin-bottom: 8px;
    }

    .card-word-text {
        font-size: 1.1em;
    }

    .sentence-card {
        padding: 14px;
        font-size: 0.95em;
    }

    .btn {
        padding: 15px 25px;
        font-size: 1.1em;
    }

    #scoreboard {
        flex-direction: column;
        gap: 15px;
        padding: 15px;
    }

    .score-item {
        font-size: 1.1em;
    }

    .popup-content {
        padding: 30px 20px;
    }

    .popup-content h2 {
        font-size: 1.8em;
    }

    .success-popup-content {
        padding: 35px 25px;
        max-width: 90%;
    }

    .success-emoji {
        font-size: 4em;
    }

    .success-title {
        font-size: 2em;
    }

    .success-message {
        font-size: 1.2em;
    }
}
