﻿* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Segoe UI", system-ui, sans-serif;
}

body {
    min-height: 100vh;
    background: radial-gradient(circle at top, #1a1a26, #0b0b10);
    color: #eaeaf2;
    display: flex;
    justify-content: center;
}

/* BOTÓN VOLVER */
.back-button {
    position: fixed;
    top: 16px;
    left: 16px;
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    color: rgba(255,255,255,0.6);
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(30,30,45,0.4);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,0.06);
    transition: all 0.2s ease;
    z-index: 10;
}

.back-button:hover {
    color: #fff;
    background: rgba(40,40,60,0.6);
}

/* CONTENEDOR */
.memory-container {
    width: 100%;
    max-width: 1200px;
    padding: 72px 16px 48px;
}

/* TABLERO */
.memory-board {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(5, 1fr);
}

/* CARTA */
.card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    cursor: pointer;
    perspective: 900px;
}

/* FLIP */
.card-inner {
    position: absolute;
    inset: 0;
    transition: transform 0.45s ease;
    transform-style: preserve-3d;
}

.card.flipped .card-inner {
    transform: rotateY(180deg);
}

/* CARAS */
.card-face {
    position: absolute;
    inset: 0;
    border-radius: 18px;
    backface-visibility: hidden;
    overflow: hidden;
}

/* REVERSO */
.card-back {
    background: rgba(28, 28, 40, 0.95);
    border: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(3rem, 6vw, 4.5rem);
    font-weight: 600;
    color: rgba(255,255,255,0.9);
}

/* FRONTAL */
.card-front {
    transform: rotateY(180deg);
}

.card-front img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ANIMACIÓN CAÍDA */
.card.fall {
    animation: fall 0.9s ease forwards;
}

@keyframes fall {
    to {
        transform: translateY(120vh) rotate(14deg);
        opacity: 0;
    }
}

/* ========================= */
/* OVERLAY VICTORIA */
/* ========================= */

.victory-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10,10,18,0.75);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
    z-index: 20;
}

.victory-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.victory-card {
    text-align: center;
    padding: 36px 32px;
    border-radius: 22px;
    background: rgba(30,30,45,0.6);
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    animation: pop 0.6s ease;
}

@keyframes pop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.victory-sub {
    font-size: 0.75rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.5);
}

.victory-text {
    font-size: 3rem;
    margin: 12px 0 20px;
    letter-spacing: 0.15em;
}

.victory-btn {
    display: inline-block;
    margin-top: 12px;
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    color: #fff;
    padding: 10px 18px;
    border-radius: 14px;
    background: linear-gradient(135deg, #6a6aff, #8f8fff);
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .memory-board { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 640px) {
    .memory-board { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 420px) {
    .memory-board { grid-template-columns: repeat(2, 1fr); }
}
