/* Memory Match Game Styles - Gamified Version */

/* Button Overrides for Game */
.difficulty-selector .ont-btn-secondary {
    position: relative !important;
    transition: all 0.3s ease !important;
    font-weight: 600 !important;
    padding: 12px 24px !important;
    border: 2px solid #e5e7eb !important;
    background: white !important;
    color: #64748b !important;
}

.difficulty-selector .ont-btn-secondary.active {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%) !important;
    color: white !important;
    border-color: #4f46e5 !important;
    box-shadow: 0 4px 16px rgba(79, 70, 229, 0.4) !important;
    transform: translateY(-2px) !important;
}

.difficulty-selector .ont-btn-secondary:hover:not(.active) {
    border-color: #4f46e5 !important;
    color: #4f46e5 !important;
    background: #f8f9ff !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08) !important;
}

.game-actions .ont-btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: 2px solid #10b981 !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
    transition: all 0.2s ease !important;
    font-weight: 600 !important;
    padding: 10px 20px !important;
}

.game-actions .ont-btn-primary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4) !important;
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

.game-actions .ont-btn-secondary {
    transition: all 0.2s ease !important;
    font-weight: 500 !important;
    padding: 10px 20px !important;
    border: 2px solid #e5e7eb !important;
}

.game-actions .ont-btn-secondary:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    border-color: #9ca3af !important;
}

/* Game Controls */
.memory-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #f8f9ff 0%, #fff 100%);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.08);
}

.difficulty-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ont-button-group {
    display: flex;
    gap: 8px;
}

.game-stats {
    display: flex;
    gap: 32px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    min-width: 80px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-actions {
    display: flex;
    gap: 8px;
}

/* Game Board */
.memory-board {
    display: grid;
    gap: 16px;
    margin: 0 auto;
    max-width: 650px;
    padding: 20px;
    background: linear-gradient(135deg, #fafbff 0%, #f0f4ff 100%);
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.12);
    min-height: 200px;
}

.memory-board-4 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.memory-board-6 {
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
}

/* Memory Card */
.memory-card {
    aspect-ratio: 1;
    perspective: 1000px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.memory-card:not(.matched):hover {
    transform: translateY(-4px);
}

.memory-card.matched {
    cursor: default;
}

.memory-card.matched:hover {
    transform: none;
}

.memory-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-front,
.memory-card-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font-size: 48px;
    font-weight: 600;
    user-select: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.memory-card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    overflow: hidden;
    transform: rotateY(0deg);
}

.memory-card-front .card-logo {
    width: 50%;
    height: 50%;
    object-fit: contain;
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

/* Add pattern to card front */
.memory-card-front::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(255, 255, 255, 0.03) 10px,
        rgba(255, 255, 255, 0.03) 20px
    );
}

/* Shine effect on card front */
.memory-card-front::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 20px;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transform: rotate(45deg);
}

.memory-card:not(.matched):not(.flipped):hover .memory-card-front::after {
    animation: shine 1.5s ease-in-out infinite;
}

@keyframes shine {
    0% {
        right: -50%;
    }
    100% {
        right: 150%;
    }
}

.memory-card-back {
    background: linear-gradient(135deg, #fff 0%, #fafbff 100%);
    border: 3px solid #e5e7eb;
    transform: rotateY(180deg);
}

/* Word cards styling */
.memory-card-back.card-word {
    font-size: 20px;
    font-weight: 700;
    color: #1f2937;
    padding: 12px;
    text-align: center;
    line-height: 1.2;
}

/* Add subtle shadow to emoji */
.memory-card-back::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    background: radial-gradient(circle at center, transparent 30%, rgba(79, 70, 229, 0.03) 100%);
    pointer-events: none;
    z-index: -1;
}

/* Matched cards */
.memory-card.matched .memory-card-back {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    border-color: #10b981;
    animation: matchPulse 0.5s ease-out;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

@keyframes matchPulse {
    0% {
        transform: rotateY(180deg) scale(1);
    }
    50% {
        transform: rotateY(180deg) scale(1.15);
        box-shadow: 0 12px 32px rgba(16, 185, 129, 0.5);
    }
    100% {
        transform: rotateY(180deg) scale(1);
    }
}

/* Remove conflicting rules */
.win-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.win-modal-content {
    background: linear-gradient(135deg, #fff 0%, #f8f9ff 100%);
    padding: 48px;
    border-radius: 24px;
    text-align: center;
    max-width: 450px;
    animation: celebration 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 20px 60px rgba(79, 70, 229, 0.3);
    border: 3px solid #4f46e5;
    position: relative;
    overflow: hidden;
}

.win-modal-content::before {
    content: '🎉';
    position: absolute;
    font-size: 120px;
    opacity: 0.1;
    top: -20px;
    right: -20px;
    animation: float 3s ease-in-out infinite;
}

.win-modal-content::after {
    content: '🎊';
    position: absolute;
    font-size: 100px;
    opacity: 0.1;
    bottom: -20px;
    left: -20px;
    animation: float 3s ease-in-out infinite reverse;
}

@keyframes celebration {
    0% {
        transform: scale(0.5) rotate(-5deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.05) rotate(2deg);
    }
    100% {
        transform: scale(1) rotate(0);
        opacity: 1;
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-20px) rotate(10deg);
    }
}

/* Play Again Button */
#playAgainBtn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: none !important;
    color: white !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    padding: 16px 40px !important;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.4) !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

#playAgainBtn:hover {
    transform: translateY(-3px) scale(1.05) !important;
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.5) !important;
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

#playAgainBtn:active {
    transform: translateY(-1px) scale(1.02) !important;
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .memory-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }
    
    .difficulty-selector,
    .game-stats,
    .game-actions {
        width: 100%;
        justify-content: center;
    }
    
    .game-stats {
        gap: 16px;
    }
    
    .memory-board {
        gap: 12px;
        padding: 16px;
    }
    
    .memory-card-front,
    .memory-card-back {
        font-size: 36px;
        border-radius: 12px;
    }
    
    .memory-card-back.card-word {
        font-size: 16px;
    }
    
    .memory-board-6 .memory-card-front,
    .memory-board-6 .memory-card-back {
        font-size: 28px;
    }
    
    .memory-board-6 .memory-card-back.card-word {
        font-size: 14px;
    }
    
    .win-modal-content {
        margin: 20px;
        padding: 36px 24px;
    }
    
    .stat-value {
        font-size: 24px;
    }
}

@media (max-width: 480px) {
    .memory-board {
        gap: 8px;
        padding: 12px;
    }
    
    .memory-card-front,
    .memory-card-back {
        font-size: 28px;
        border-radius: 10px;
    }
    
    .memory-card-back.card-word {
        font-size: 14px;
    }
    
    .memory-board-6 .memory-card-front,
    .memory-board-6 .memory-card-back {
        font-size: 20px;
    }
    
    .memory-board-6 .memory-card-back.card-word {
        font-size: 11px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .stat-item {
        padding: 8px 16px;
        min-width: 70px;
    }
}
