/* Memory Game Styles - Company Brand Colors */
/* Primary: #a3c34c (Green) | Secondary: #345c5c (Teal) */

/* Reset and base styles */
* {
    box-sizing: border-box;
}

/* Game section - proper spacing from navbar and footer */
.game-section {
    padding-top: 120px !important;
    padding-bottom: 60px !important;
    min-height: calc(100vh - 200px);
}

/* Game Container - proper constraints */
.game-container {
    width: 100%;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 15px;
    padding-right: 15px;
}

/* Game Header - below cards */
.game-header {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 25px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.score-badge {
    font-size: 1.5rem !important;
    font-weight: bold !important;
    padding: 12px 24px !important;
    background: linear-gradient(135deg, #345c5c 0%, #2a4a4a 100%) !important;
    color: white !important;
    border-radius: 25px !important;
    box-shadow: 0 4px 15px rgba(52, 92, 92, 0.3);
    border: 2px solid #a3c34c;
}

/* Game Area - centered wrapper */
.game-area {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 0;
}

/* Memory Grid - perfectly centered with consistent spacing */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 200px);
    gap: 25px;
    justify-content: center;
    align-items: start;
    margin: 0 auto;
}

/* Responsive grid adjustments */
@media (max-width: 1200px) {
    .memory-grid {
        grid-template-columns: repeat(4, minmax(160px, 200px));
        gap: 20px;
        padding: 0 20px;
    }
}

@media (max-width: 900px) {
    .memory-grid {
        grid-template-columns: repeat(3, minmax(150px, 180px));
        gap: 20px;
    }
}

@media (max-width: 650px) {
    .memory-grid {
        grid-template-columns: repeat(2, minmax(140px, 180px));
        gap: 15px;
    }
}

@media (max-width: 400px) {
    .memory-grid {
        grid-template-columns: repeat(2, minmax(120px, 150px));
        gap: 12px;
    }
}

/* Memory Card - Square with 3D flip */
.memory-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    perspective: 1000px;
}

.memory-card:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.memory-card:active {
    transform: scale(0.98);
}

/* Card Inner - flip container */
.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

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

/* Card Faces - front and back */
.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Card Back - green with question mark */
.card-back {
    background: linear-gradient(135deg, #a3c34c 0%, #8ab83c 100%);
    border: 3px solid #345c5c;
    color: white;
    font-size: 3rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.card-back::before {
    content: '?';
}

/* Card Front - white with image */
.card-front {
    background: white;
    border: 3px solid #345c5c;
    transform: rotateY(180deg);
    overflow: hidden;
    /* Use column flex to stack image and text */
    flex-direction: column;
    justify-content: space-between;
    padding: 5px;
}

.card-front img {
    width: 100%;
    height: 80%;
    /* Reduce height to make room for text */
    object-fit: cover;
    border-radius: 6px;
}

/* Card Text - Name below image */
.card-text {
    font-size: 1rem;
    font-weight: bold;
    color: #345c5c;
    text-align: center;
    margin-top: 5px;
    width: 100%;
    /* Ensure text doesn't overflow */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Matched cards - green glow effect */
.memory-card.matched .card-face {
    border-color: #a3c34c;
    box-shadow: 0 0 20px rgba(163, 195, 76, 0.6), 0 4px 8px rgba(0, 0, 0, 0.2);
}

.memory-card.matched {
    animation: matchPulse 0.5s ease;
    pointer-events: none;
}

@keyframes matchPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }
}

/* Wrong match - shake animation */
.memory-card.wrong {
    animation: shake 0.4s ease;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }
}

/* Result Modal */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.result-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border: 4px solid #a3c34c;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.result-content h2 {
    color: #345c5c;
    font-size: 2.5rem;
    margin-bottom: 20px;
    font-weight: bold;
}

.result-content p {
    color: #666;
    font-size: 1.5rem;
    margin-bottom: 30px;
}

.result-content button,
.result-content a {
    margin: 10px;
    padding: 12px 30px;
    font-size: 1.1rem;
    border-radius: 25px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.result-content .btn-primary {
    background: linear-gradient(135deg, #a3c34c 0%, #8ab83c 100%);
    color: white;
}

.result-content .btn-primary:hover {
    background: linear-gradient(135deg, #8ab83c 0%, #7aa62c 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(163, 195, 76, 0.4);
}

.result-content .btn-default {
    background: #345c5c;
    color: white;
}

.result-content .btn-default:hover {
    background: #2a4a4a;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 92, 92, 0.4);
}

/* Game notification */
.game-notification {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 15px 30px;
    border-radius: 25px;
    border: 3px solid #a3c34c;
    color: #345c5c;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    animation: slideDown 0.3s ease;
    opacity: 1;
    transition: opacity 0.5s ease;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* Oval On-Screen Alert (Bulletproof Centering) */
.game-notification-oval {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    padding: 20px 60px !important;
    border-radius: 50px !important;
    color: white !important;
    font-size: 24px !important;
    font-weight: 900 !important;
    text-align: center !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5) !important;
    z-index: 2147483647 !important;
    border: 5px solid white !important;
    min-width: 300px !important;
    opacity: 1 !important;
    animation: simplePop 0.4s ease-out forwards !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.game-notification-oval.success {
    background-color: #a3c34c !important;
    background-image: linear-gradient(135deg, #a3c34c, #8dae36) !important;
}

.game-notification-oval.error {
    background-color: #e74c3c !important;
    background-image: linear-gradient(135deg, #e74c3c, #c0392b) !important;
}

@keyframes simplePop {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }

    80% {
        transform: translate(-50%, -50%) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}