/* ========================================
   CUGINIPARTY - MEMORY
======================================== */


/* ========================================
   START SCREEN
======================================== */

.memory-start-screen {
    width: 100%;
    max-width: 920px;

    margin: 0 auto;
    padding: 20px;

    text-align: center;
}

.memory-hero-icon {
    width: 100px;
    height: 100px;

    margin: 0 auto 18px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 30px;

    background:
        linear-gradient(
            135deg,
            #ede9fe,
            #ddd6fe 55%,
            #dbeafe
        );

    font-size: 54px;

    box-shadow:
        0 20px 50px
        rgba(99, 102, 241, 0.18);
}

.memory-kicker,
.memory-victory-kicker {
    color: #7c3aed;

    font-size: 0.68rem;
    font-weight: 1000;

    letter-spacing: 0.20em;
    text-transform: uppercase;
}

.memory-start-screen h1 {
    margin: 7px 0 0;

    color:
        var(--text-color, #111827);

    font-size:
        clamp(2.3rem, 7vw, 4rem);

    font-weight: 1000;

    letter-spacing: -0.07em;
}

.memory-hero-text {
    max-width: 590px;

    margin: 14px auto 30px;

    color:
        var(--muted-text, #6b7280);

    font-size: 0.98rem;
    line-height: 1.65;
}


/* ========================================
   DIFFICULTY
======================================== */

.memory-difficulty-title {
    margin-bottom: 13px;

    color:
        var(--text-color, #111827);

    font-size: 0.82rem;
    font-weight: 1000;

    text-transform: uppercase;
    letter-spacing: 0.10em;
}

.memory-difficulty-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 13px;

    max-width: 760px;

    margin: 0 auto 22px;
}

.memory-difficulty-card {
    min-width: 0;

    padding: 20px 14px;

    border:
        2px solid
        var(--border-color, #e5e7eb);

    border-radius: 20px;

    background:
        var(--card-bg, #ffffff);

    color:
        var(--text-color, #111827);

    cursor: pointer;

    box-shadow:
        0 10px 28px
        rgba(15, 23, 42, 0.06);

    transition:
        transform 0.18s ease,
        border-color 0.18s ease,
        box-shadow 0.18s ease,
        background 0.18s ease;
}

.memory-difficulty-card:hover {
    transform: translateY(-3px);

    box-shadow:
        0 16px 35px
        rgba(15, 23, 42, 0.10);
}

.memory-difficulty-card.selected {
    border-color: #7c3aed;

    background:
        linear-gradient(
            145deg,
            #faf5ff,
            #f5f3ff
        );

    box-shadow:
        0 15px 35px
        rgba(124, 58, 237, 0.14);
}

.memory-difficulty-icon {
    display: block;

    margin-bottom: 8px;

    font-size: 28px;
}

.memory-difficulty-card strong {
    display: block;

    font-size: 0.92rem;
    font-weight: 1000;
}

.memory-difficulty-card small {
    display: block;

    margin-top: 5px;

    color:
        var(--muted-text, #6b7280);

    font-size: 0.67rem;
}


.memory-start-info {
    display: flex;

    justify-content: center;
    align-items: center;

    flex-wrap: wrap;

    gap: 10px;

    margin-bottom: 24px;
}

.memory-start-info > div {
    display: flex;

    align-items: center;

    gap: 7px;

    padding: 9px 13px;

    border-radius: 14px;

    background:
        var(--secondary-bg, #f3f4f6);

    border:
        1px solid
        var(--border-color, #e5e7eb);
}

.memory-start-info span {
    font-size: 17px;
}

.memory-start-info strong {
    color:
        var(--text-color, #111827);

    font-size: 0.68rem;
    font-weight: 900;
}

.memory-main-button {
    min-width: 240px !important;

    box-shadow:
        0 15px 35px
        rgba(124, 58, 237, 0.20);
}


/* ========================================
   GAME SCREEN
======================================== */

.memory-game-screen {
    width: 100%;
    max-width: 1100px;

    margin: 0 auto;
    padding: 15px;

    border-radius: 30px;

    background:
        radial-gradient(
            circle at 50% 0%,
            rgba(124, 58, 237, 0.13),
            transparent 35%
        ),
        linear-gradient(
            145deg,
            #18181b,
            #030712
        );

    border:
        1px solid
        rgba(255,255,255,0.10);

    box-shadow:
        0 35px 100px
        rgba(0,0,0,0.34);

    box-sizing: border-box;

    overflow: hidden;
}

.memory-game-screen[hidden],
.memory-victory-screen[hidden] {
    display: none;
}


/* ========================================
   GAME HEADER
======================================== */

.memory-game-header {
    display: flex;

    justify-content: space-between;
    align-items: center;

    gap: 15px;

    margin-bottom: 12px;
}

.memory-game-title {
    display: flex;

    align-items: center;

    gap: 10px;

    min-width: 0;
}

.memory-game-title > span {
    width: 43px;
    height: 43px;

    flex: 0 0 auto;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 13px;

    background:
        rgba(124, 58, 237, 0.18);

    font-size: 22px;
}

.memory-game-kicker {
    display: block;

    margin-bottom: 1px;

    color:
        rgba(255,255,255,0.42);

    font-size: 0.48rem;

    font-weight: 1000;

    letter-spacing: 0.15em;
}

.memory-game-title h2 {
    margin: 0;

    color: #ffffff;

    font-size: 1.18rem;

    font-weight: 1000;
}

.memory-back-button {
    width: auto !important;
    min-width: 90px !important;
    margin: 0 !important;
}


/* ========================================
   STATS
======================================== */

.memory-stats {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 8px;

    margin-bottom: 9px;
}

.memory-stat {
    display: flex;

    justify-content: center;
    align-items: center;

    gap: 8px;

    min-width: 0;

    padding: 9px 8px;

    border-radius: 14px;

    background:
        rgba(255,255,255,0.06);

    border:
        1px solid
        rgba(255,255,255,0.08);

    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.memory-stat > span {
    font-size: 17px;
}

.memory-stat small,
.memory-stat strong {
    display: block;
}

.memory-stat small {
    margin-bottom: 2px;

    color:
        rgba(255,255,255,0.40);

    font-size: 0.52rem;

    font-weight: 900;

    text-transform: uppercase;
}

.memory-stat strong {
    color: #ffffff;

    font-size: 0.83rem;

    font-weight: 1000;

    font-variant-numeric: tabular-nums;
}


/* ========================================
   PROGRESS
======================================== */

.memory-progress {
    width: 100%;
    height: 6px;

    margin-bottom: 11px;

    overflow: hidden;

    border-radius: 999px;

    background:
        rgba(255,255,255,0.08);
}

.memory-progress-bar {
    width: 0%;
    height: 100%;

    border-radius: inherit;

    background:
        linear-gradient(
            90deg,
            #7c3aed,
            #a855f7,
            #60a5fa
        );

    transition:
        width 0.25s ease;
}


/* ========================================
   MEMORY BOARD
======================================== */

.memory-board {
    width: 100%;

    margin: 0 auto;

    display: grid;

    gap: 9px;

    perspective: 1000px;

    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.memory-board.easy {
    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    max-width: 720px;
}

.memory-board.medium {
    grid-template-columns:
        repeat(5, minmax(0, 1fr));

    max-width: 850px;
}

.memory-board.hard {
    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    max-width: 850px;
}


/* ========================================
   CARD
======================================== */

.memory-card {
    position: relative;

    width: 100%;

    aspect-ratio: 1 / 1;

    border: 0;

    padding: 0;

    background: transparent;

    cursor: pointer;

    perspective: 900px;

    -webkit-tap-highlight-color: transparent;
}

.memory-card:disabled {
    cursor: default;
}

.memory-card-inner {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    transform-style: preserve-3d;

    transition:
        transform 0.42s
        cubic-bezier(0.2, 0.7, 0.2, 1);
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-face {
    position: absolute;

    inset: 0;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 16px;

    overflow: hidden;

    box-sizing: border-box;

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}


/* ========================================
   CARD BACK
======================================== */

.memory-card-back {
    background:
        linear-gradient(
            145deg,
            #312e81,
            #6d28d9
        );

    border:
        2px solid
        rgba(255,255,255,0.15);

    box-shadow:
        0 7px 17px
        rgba(0,0,0,0.23);

    color: rgba(255,255,255,0.9);

    font-size:
        clamp(
            1.3rem,
            5vw,
            2rem
        );
}

.memory-card-back::before {
    content: "";

    position: absolute;

    inset: 7px;

    border-radius: 11px;

    border:
        1px dashed
        rgba(255,255,255,0.25);
}


/* ========================================
   CARD FRONT
======================================== */

.memory-card-front {
    transform:
        rotateY(180deg);

    background:
        linear-gradient(
            145deg,
            #ffffff,
            #f4f4f5
        );

    border:
        2px solid
        rgba(255,255,255,0.8);

    box-shadow:
        0 8px 20px
        rgba(0,0,0,0.22);

    font-size:
        clamp(
            1.8rem,
            6vw,
            3rem
        );
}


/* ========================================
   MATCH
======================================== */

.memory-card.matched .memory-card-front {
    border-color:
        rgba(34,197,94,0.75);

    box-shadow:
        0 0 0 2px
        rgba(34,197,94,0.18),
        0 8px 22px
        rgba(34,197,94,0.18);

    animation:
        memoryMatchPulse
        0.45s ease;
}

@keyframes memoryMatchPulse {

    0% {
        transform:
            rotateY(180deg)
            scale(1);
    }

    50% {
        transform:
            rotateY(180deg)
            scale(1.07);
    }

    100% {
        transform:
            rotateY(180deg)
            scale(1);
    }

}


/* ========================================
   WRONG
======================================== */

.memory-card.wrong .memory-card-inner {
    animation:
        memoryWrongShake
        0.35s ease;
}

@keyframes memoryWrongShake {

    0%,
    100% {
        transform:
            rotateY(180deg)
            translateX(0);
    }

    25% {
        transform:
            rotateY(180deg)
            translateX(-6px);
    }

    75% {
        transform:
            rotateY(180deg)
            translateX(6px);
    }

}


/* ========================================
   TIP
======================================== */

.memory-game-tip {
    margin-top: 10px;

    color:
        rgba(255,255,255,0.38);

    text-align: center;

    font-size: 0.64rem;
}


/* ========================================
   VICTORY
======================================== */

.memory-victory-screen {
    width: 100%;
    max-width: 760px;

    margin: 0 auto;

    padding: 20px;
}

.memory-victory-card {
    position: relative;

    overflow: hidden;

    padding:
        45px
        35px
        35px;

    border-radius: 30px;

    background:
        var(--card-bg, #ffffff);

    border:
        1px solid
        var(--border-color, #e5e7eb);

    box-shadow:
        0 30px 85px
        rgba(0,0,0,0.15);

    text-align: center;
}

.memory-victory-glow {
    position: absolute;

    width: 320px;
    height: 320px;

    left: 50%;
    top: -190px;

    transform: translateX(-50%);

    border-radius: 50%;

    background:
        rgba(168,85,247,0.18);

    filter: blur(25px);

    pointer-events: none;
}

.memory-victory-icon {
    position: relative;

    width: 96px;
    height: 96px;

    margin: 0 auto 17px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 29px;

    background:
        linear-gradient(
            135deg,
            #ede9fe,
            #ddd6fe,
            #dbeafe
        );

    font-size: 50px;

    box-shadow:
        0 18px 45px
        rgba(124,58,237,0.18);
}

.memory-victory-card h2 {
    position: relative;

    margin:
        7px
        0
        0;

    color:
        var(--text-color, #111827);

    font-size:
        clamp(2rem, 6vw, 3.3rem);

    font-weight: 1000;

    letter-spacing: -0.06em;
}

.memory-victory-message {
    max-width: 500px;

    margin: 13px auto 0;

    color:
        var(--muted-text, #6b7280);

    font-size: 0.9rem;

    line-height: 1.6;
}

.memory-result-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 11px;

    max-width: 480px;

    margin: 25px auto 15px;
}

.memory-result-grid > div {
    padding: 16px;

    border-radius: 17px;

    background:
        var(--secondary-bg, #f3f4f6);
}

.memory-result-grid span,
.memory-result-grid strong {
    display: block;
}

.memory-result-grid span {
    margin-bottom: 5px;

    color:
        var(--muted-text, #6b7280);

    font-size: 0.68rem;
    font-weight: 800;
}

.memory-result-grid strong {
    color:
        var(--text-color, #111827);

    font-size: 1rem;
    font-weight: 1000;

    font-variant-numeric: tabular-nums;
}

.memory-performance {
    margin: 13px 0 0;
}

.memory-performance span {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    padding: 8px 16px;

    border-radius: 999px;

    background:
        #f3e8ff;

    color:
        #7c3aed;

    font-size: 0.72rem;
    font-weight: 1000;
}


/* ========================================
   DARK MODE
======================================== */

body.dark-mode .memory-start-screen {
    color: #f3f4fa;
}

body.dark-mode .memory-start-screen h1 {
    color: #f3f4fa;
}

body.dark-mode .memory-hero-text {
    color: #aeb2c3;
}

body.dark-mode .memory-difficulty-title {
    color: #f3f4fa;
}

body.dark-mode .memory-difficulty-card {
    background: #181b29;
    border-color: rgba(255, 255, 255, 0.08);
    color: #f3f4fa;
}

body.dark-mode .memory-difficulty-card:hover {
    border-color: rgba(166, 155, 255, 0.35);
}

body.dark-mode .memory-difficulty-card.selected {
    background:
        linear-gradient(
            145deg,
            #1f1630,
            #21183a
        );

    border-color: #a855f7;

    box-shadow:
        0 15px 35px
        rgba(124, 58, 237, 0.18);
}

body.dark-mode .memory-difficulty-card strong {
    color: #ffffff;
}

body.dark-mode .memory-difficulty-card small {
    color: #aeb2c3;
}

body.dark-mode .memory-start-info > div {
    background: #181b29;
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .memory-start-info strong {
    color: #f3f4fa;
}


/* ========================================
   CARTE
======================================== */

body.dark-mode .memory-card-front {
    background:
        linear-gradient(
            145deg,
            #272a35,
            #181b29
        );

    border-color: #3f4352;

    color: #ffffff;
}


/* ========================================
   VITTORIA
======================================== */

body.dark-mode .memory-victory-screen {
    color: #f3f4fa;
}

body.dark-mode .memory-victory-card {
    background: #181b29;
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode .memory-victory-card h2 {
    color: #ffffff;
}

body.dark-mode .memory-victory-message {
    color: #aeb2c3;
}

body.dark-mode .memory-result-grid > div {
    background: #252938;
}

body.dark-mode .memory-result-grid span {
    color: #aeb2c3;
}

body.dark-mode .memory-result-grid strong {
    color: #ffffff;
}

body.dark-mode .memory-performance span {
    background: rgba(124, 58, 237, 0.18);
    color: #c4b5fd;
}


/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 850px) {

    .memory-game-screen {
        padding: 10px;

        border-radius: 22px;
    }

    .memory-board {
        gap: 7px;
    }

    .memory-card-face {
        border-radius: 13px;
    }

}


@media (max-width: 650px) {

    .memory-start-screen {
        padding: 10px;
    }

    .memory-hero-icon {
        width: 78px;
        height: 78px;

        border-radius: 23px;

        font-size: 40px;
    }

    .memory-hero-text {
        font-size: 0.84rem;
    }

    .memory-difficulty-grid {
        grid-template-columns:
            1fr;

        max-width: 360px;
    }

    .memory-difficulty-card {
        display: grid;

        grid-template-columns:
            auto 1fr;

        grid-template-rows:
            auto auto;

        column-gap: 11px;

        text-align: left;

        padding: 13px 15px;
    }

    .memory-difficulty-icon {
        grid-row: 1 / 3;

        margin: 0;

        align-self: center;

        font-size: 27px;
    }

    .memory-difficulty-card strong {
        align-self: end;
    }

    .memory-difficulty-card small {
        align-self: start;
    }

    .memory-start-info {
        gap: 6px;
    }

    .memory-start-info > div {
        padding: 8px 10px;
    }

    .memory-main-button {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 360px;
    }

    .memory-game-header {
        gap: 8px;
    }

    .memory-game-title > span {
        width: 36px;
        height: 36px;

        border-radius: 11px;

        font-size: 18px;
    }

    .memory-game-kicker {
        font-size: 0.40rem;
    }

    .memory-game-title h2 {
        font-size: 0.95rem;
    }

    .memory-back-button {
        min-width: 70px !important;

        padding-left: 10px !important;
        padding-right: 10px !important;
    }

    .memory-stats {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 6px;
    }

    .memory-stat {
        justify-content: flex-start;

        padding: 8px;
    }

    .memory-stat > span {
        font-size: 15px;
    }

    .memory-stat small {
        font-size: 0.46rem;
    }

    .memory-stat strong {
        font-size: 0.72rem;
    }

    .memory-board {
        gap: 6px;
    }

    .memory-card-face {
        border-radius: 11px;
    }

    .memory-card-back {
        font-size: 1.25rem;
    }

    .memory-card-front {
        font-size: 1.7rem;
    }

    .memory-victory-card {
        padding:
            34px
            17px
            26px;

        border-radius: 23px;
    }

}


@media (max-width: 390px) {

    .memory-board {
        gap: 4px;
    }

    .memory-card-face {
        border-radius: 8px;
    }

    .memory-card-back {
        font-size: 1rem;
    }

    .memory-card-front {
        font-size: 1.35rem;
    }

    .memory-stat {
        padding: 6px;
    }

    .memory-stat > span {
        font-size: 13px;
    }

    .memory-stat small {
        font-size: 0.40rem;
    }

    .memory-stat strong {
        font-size: 0.64rem;
    }

}