﻿/* =========================================================
   MEMORY MATCH
   ========================================================= */

* {
    box-sizing: border-box;
}

.memory-match-page {
    min-height: calc(100vh - 120px);
    padding: 35px 20px 55px;
    background: radial-gradient(circle at 10% 10%, rgba(95, 91, 255, .16), transparent 30%), radial-gradient(circle at 90% 70%, rgba(0, 211, 255, .10), transparent 30%), #080b16;
    color: #ffffff;
}

.memory-container {
    width: min(100%, 900px);
    margin: 0 auto;
}


/* =========================================================
   NAVIGATION
   ========================================================= */

.game-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    border-radius: 12px;
    color: #aeb5d1;
    background: rgba(255,255,255,.055);
    border: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: .2s ease;
}

    .back-link:hover {
        color: #ffffff;
        background: rgba(255,255,255,.1);
        transform: translateX(-2px);
    }

.sound-button {
    width: 43px;
    height: 43px;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 13px;
    background: rgba(255,255,255,.06);
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    transition: .2s ease;
}

    .sound-button:hover {
        background: rgba(255,255,255,.11);
        transform: translateY(-2px);
    }


/* =========================================================
   TITLE
   ========================================================= */

.game-title {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 25px;
}

.game-title-icon {
    width: 62px;
    height: 62px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border-radius: 19px;
    background: linear-gradient(135deg, #6557ff, #bd4cff);
    box-shadow: 0 15px 40px rgba(105, 81, 255, .32), inset 0 1px 0 rgba(255,255,255,.25);
    font-size: 30px;
}

.game-eyebrow {
    margin-bottom: 5px;
    color: #9288ff;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1.7px;
}

.game-title h1 {
    margin: 0;
    font-size: clamp(28px, 5vw, 42px);
    line-height: 1;
    font-weight: 900;
    letter-spacing: -1px;
}

.game-title p {
    margin: 8px 0 0;
    color: #858ca7;
    font-size: 14px;
}


/* =========================================================
   STATS
   ========================================================= */

.game-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.stat-box {
    padding: 13px 10px;
    text-align: center;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 15px;
    background: rgba(255,255,255,.045);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.025);
}

    .stat-box span {
        display: block;
        margin-bottom: 3px;
        color: #727a99;
        font-size: 9px;
        font-weight: 900;
        letter-spacing: 1.2px;
        text-transform: uppercase;
    }

    .stat-box strong {
        font-size: 22px;
        font-weight: 900;
    }

.timer-box strong {
    color: #ffd35a;
}


/* =========================================================
   GAME CARD
   ========================================================= */

.game-card {
    position: relative;
    padding: 24px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.09);
    border-radius: 25px;
    background: linear-gradient( 145deg, rgba(255,255,255,.085), rgba(255,255,255,.025) );
    box-shadow: 0 30px 90px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.035);
}

    .game-card::before {
        content: "";
        position: absolute;
        width: 350px;
        height: 350px;
        top: -250px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 50%;
        background: rgba(106, 87, 255, .13);
        filter: blur(50px);
        pointer-events: none;
    }


/* =========================================================
   GAME INFO
   ========================================================= */

.game-info {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 14px;
}

.info-label {
    color: #8e86ff;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 1.5px;
}

.game-info h2 {
    margin: 4px 0 0;
    font-size: 18px;
    font-weight: 800;
}

.mistakes-box {
    min-width: 90px;
    padding: 9px 13px;
    text-align: center;
    border-radius: 13px;
    background: rgba(255,255,255,.045);
}

    .mistakes-box span {
        display: block;
        color: #777f9c;
        font-size: 9px;
        font-weight: 800;
    }

    .mistakes-box strong {
        font-size: 18px;
    }


/* =========================================================
   PROGRESS
   ========================================================= */

.progress-track {
    position: relative;
    z-index: 1;
    height: 5px;
    margin-bottom: 20px;
    overflow: hidden;
    border-radius: 20px;
    background: rgba(255,255,255,.06);
}

.progress-fill {
    width: 0%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #6858ff, #d44dff);
    transition: width .35s ease;
}


/* =========================================================
   MEMORY BOARD
   ========================================================= */

.memory-board {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    max-width: 650px;
    margin: 0 auto;
}


/* =========================================================
   MEMORY CARD
   ========================================================= */

.memory-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 0;
    border: 0;
    background: transparent;
    perspective: 900px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.memory-card-inner {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.2,.75,.25,1);
}

.memory-card.flipped .memory-card-inner,
.memory-card.matched .memory-card-inner {
    transform: rotateY(180deg);
}

.memory-card-face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: 18px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-back {
    overflow: hidden;
    border: 1px solid rgba(255,255,255,.1);
    background: radial-gradient( circle at 30% 20%, rgba(255,255,255,.13), transparent 28% ), linear-gradient( 145deg, #25234b, #15162e );
    box-shadow: 0 12px 25px rgba(0,0,0,.2), inset 0 1px 0 rgba(255,255,255,.1);
}

    .card-back::before {
        content: "?";
        display: grid;
        place-items: center;
        width: 47%;
        height: 47%;
        border: 1px solid rgba(155,143,255,.28);
        border-radius: 14px;
        color: rgba(164,153,255,.65);
        font-size: clamp(20px, 4vw, 30px);
        font-weight: 900;
        background: rgba(111,94,255,.08);
    }

.card-front {
    transform: rotateY(180deg);
    border: 1px solid rgba(255,255,255,.11);
    background: linear-gradient( 145deg, rgba(255,255,255,.13), rgba(255,255,255,.055) );
    box-shadow: 0 15px 30px rgba(0,0,0,.22), inset 0 1px 0 rgba(255,255,255,.1);
    font-size: clamp(30px, 7vw, 48px);
}

.memory-card:hover:not(.flipped):not(.matched) .card-back {
    transform: translateY(-3px);
    border-color: rgba(135,119,255,.45);
    box-shadow: 0 15px 30px rgba(91,72,230,.22), inset 0 1px 0 rgba(255,255,255,.1);
}

.memory-card.matched .card-front {
    border-color: rgba(57,226,151,.5);
    background: linear-gradient( 145deg, rgba(50,220,145,.18), rgba(255,255,255,.05) );
    box-shadow: 0 0 25px rgba(50,220,145,.12), inset 0 1px 0 rgba(255,255,255,.1);
}

.memory-card.match-animation .card-front {
    animation: matchedPulse .5s ease;
}

@keyframes matchedPulse {

    0% {
        transform: rotateY(180deg) scale(1);
    }

    45% {
        transform: rotateY(180deg) scale(1.08);
    }

    100% {
        transform: rotateY(180deg) scale(1);
    }
}

.memory-card.wrong .memory-card-inner {
    animation: cardShake .38s ease;
}

@keyframes cardShake {

    0%, 100% {
        transform: rotateY(180deg) translateX(0);
    }

    25% {
        transform: rotateY(180deg) translateX(-7px);
    }

    75% {
        transform: rotateY(180deg) translateX(7px);
    }
}


/* =========================================================
   MESSAGE
   ========================================================= */

.game-message {
    position: relative;
    z-index: 1;
    min-height: 23px;
    margin-top: 17px;
    color: #858ca7;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
}

    .game-message.success {
        color: #48df9a;
    }

    .game-message.warning {
        color: #ff7086;
    }


/* =========================================================
   OVERLAY
   ========================================================= */

.game-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(5,7,15,.82);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

    .game-overlay.hidden {
        display: none;
    }

.overlay-card {
    width: min(100%, 470px);
    padding: 35px;
    text-align: center;
    border: 1px solid rgba(255,255,255,.11);
    border-radius: 27px;
    background: linear-gradient( 145deg, rgba(29,31,57,.97), rgba(13,15,30,.97) );
    box-shadow: 0 40px 100px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.07);
    animation: overlayAppear .35s ease;
}

@keyframes overlayAppear {

    from {
        opacity: 0;
        transform: translateY(18px) scale(.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.overlay-icon,
.result-icon {
    width: 82px;
    height: 82px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border-radius: 25px;
    background: linear-gradient(135deg, #6657ff, #bd4cff);
    box-shadow: 0 20px 50px rgba(104,80,255,.32), inset 0 1px 0 rgba(255,255,255,.2);
    font-size: 38px;
}

.result-icon {
    background: linear-gradient(135deg, #15bb7a, #35dca0);
}

.overlay-label {
    margin-bottom: 7px;
    color: #9b91ff;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 2px;
}

.overlay-card h2 {
    margin: 0;
    font-size: 32px;
    font-weight: 900;
    letter-spacing: -.8px;
}

.overlay-card > p {
    margin: 10px auto 25px;
    max-width: 360px;
    color: #858ca6;
    font-size: 13px;
    line-height: 1.6;
}


/* =========================================================
   INSTRUCTIONS
   ========================================================= */

.instructions {
    display: grid;
    gap: 8px;
    margin-bottom: 24px;
    text-align: left;
}

.instruction {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border: 1px solid rgba(255,255,255,.055);
    border-radius: 14px;
    background: rgba(255,255,255,.035);
}

    .instruction > span {
        width: 36px;
        height: 36px;
        display: grid;
        place-items: center;
        flex-shrink: 0;
        border-radius: 11px;
        background: rgba(104,88,255,.12);
        font-size: 18px;
    }

    .instruction strong {
        display: block;
        font-size: 12px;
    }

    .instruction small {
        display: block;
        margin-top: 2px;
        color: #737b98;
        font-size: 10px;
    }


/* =========================================================
   BUTTON
   ========================================================= */

.start-button {
    width: 100%;
    min-height: 55px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    border: 0;
    border-radius: 16px;
    background: linear-gradient(135deg, #6758ff, #c34bff);
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .8px;
    cursor: pointer;
    box-shadow: 0 15px 40px rgba(101,76,255,.3);
    transition: .2s ease;
}

    .start-button:hover {
        transform: translateY(-3px);
        box-shadow: 0 20px 50px rgba(101,76,255,.42);
    }

    .start-button:active {
        transform: scale(.97);
    }


/* =========================================================
   RESULT
   ========================================================= */

.final-score {
    margin: 20px 0 13px;
    padding: 17px;
    border: 1px solid rgba(255,255,255,.06);
    border-radius: 17px;
    background: rgba(255,255,255,.045);
}

    .final-score span {
        display: block;
        color: #777f9c;
        font-size: 9px;
        font-weight: 900;
        letter-spacing: 1.4px;
    }

    .final-score strong {
        display: block;
        margin-top: 4px;
        font-size: 45px;
        font-weight: 900;
    }

.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
    margin-bottom: 18px;
}

    .result-stats div {
        padding: 12px;
        border-radius: 14px;
        background: rgba(255,255,255,.04);
    }

    .result-stats span {
        display: block;
        color: #737b97;
        font-size: 8px;
        font-weight: 900;
        letter-spacing: 1px;
    }

    .result-stats strong {
        display: block;
        margin-top: 4px;
        font-size: 19px;
    }

.games-link {
    display: inline-block;
    margin-top: 18px;
    color: #9b91ff;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}

    .games-link:hover {
        color: #ffffff;
    }


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .memory-match-page {
        min-height: calc(100vh - 80px);
        padding: 22px 10px 35px;
    }

    .game-title {
        gap: 11px;
        margin-bottom: 17px;
    }

    .game-title-icon {
        width: 50px;
        height: 50px;
        border-radius: 15px;
        font-size: 24px;
    }

    .game-title h1 {
        font-size: 28px;
    }

    .game-title p {
        margin-top: 5px;
        font-size: 11px;
    }

    .game-stats {
        gap: 6px;
    }

    .stat-box {
        padding: 9px 4px;
        border-radius: 12px;
    }

        .stat-box span {
            font-size: 8px;
        }

        .stat-box strong {
            font-size: 18px;
        }

    .game-card {
        padding: 14px;
        border-radius: 20px;
    }

    .memory-board {
        gap: 8px;
    }

    .memory-card-face {
        border-radius: 13px;
    }

    .card-back::before {
        border-radius: 9px;
    }

    .game-info h2 {
        font-size: 15px;
    }

    .mistakes-box {
        min-width: 72px;
        padding: 7px 9px;
    }

    .overlay-card {
        padding: 25px 18px;
        border-radius: 23px;
    }

    .overlay-icon,
    .result-icon {
        width: 68px;
        height: 68px;
        border-radius: 20px;
        font-size: 31px;
    }

    .overlay-card h2 {
        font-size: 27px;
    }
}


@media (max-width: 400px) {

    .memory-match-page {
        padding-left: 7px;
        padding-right: 7px;
    }

    .memory-board {
        gap: 6px;
    }

    .memory-card-face {
        border-radius: 10px;
    }

    .game-card {
        padding: 11px;
    }

    .game-info {
        gap: 8px;
    }

    .info-label {
        font-size: 8px;
    }

    .game-info h2 {
        font-size: 13px;
    }

    .mistakes-box {
        min-width: 63px;
    }
}
