:root {
    --black: #070707;
    --ruby: #d3134b;
    --white: #fff;
    --muted: rgba(255,255,255,.52);
    --line: rgba(255,255,255,.13);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 75% 20%, rgba(211,19,75,.10), transparent 35%),
        #070707;
    color: white;
    font-family: "Inter", sans-serif;
}

button { font-family: inherit; }

.memory-page { min-height: 100vh; display: flex; flex-direction: column; }

.memory-nav {
    height: 86px;
    padding: 0 7%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.logo {
    color: white;
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .07em;
}
.logo span { color: var(--ruby); }

.memory-nav nav { display: flex; gap: 34px; }
.memory-nav nav a {
    color: rgba(255,255,255,.48);
    text-decoration: none;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .16em;
}
.memory-nav nav a:hover,
.memory-nav nav a.active { color: white; }

.memory-main {
    width: min(1000px, 92%);
    margin: auto;
    padding: 85px 0 100px;
}

.memory-heading { margin-bottom: 45px; }

.eyebrow {
    margin-bottom: 20px;
    color: var(--ruby);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .28em;
}

.memory-heading h1 {
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(75px, 10vw, 125px);
    font-weight: 500;
    line-height: .72;
    letter-spacing: -.04em;
}

.memory-heading h1 span,
.result-panel h2 span {
    color: transparent;
    -webkit-text-stroke: 1px rgba(255,255,255,.9);
}

.intro {
    width: 390px;
    max-width: 100%;
    margin-top: 35px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.game-panel,
.result-panel {
    padding: 30px;
    border: 1px solid rgba(211,19,75,.45);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255,255,255,.035), rgba(255,255,255,.01));
}

.game-top {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--line);
    padding-bottom: 22px;
    margin-bottom: 25px;
}

.game-top div {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.game-top div:nth-child(2) { text-align: center; align-items: center; }
.game-top div:nth-child(3) { text-align: right; align-items: flex-end; }

.game-top span {
    color: rgba(255,255,255,.35);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .18em;
}

.game-top strong {
    color: var(--ruby);
    font-size: 18px;
    letter-spacing: .04em;
}

.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.memory-card {
    position: relative;
    aspect-ratio: 3 / 4;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    background: #101010;
    cursor: pointer;
    perspective: 900px;
}

.card-inner {
    position: absolute;
    inset: 0;
    transition: transform .45s ease;
    transform-style: preserve-3d;
}

.memory-card.flipped .card-inner,
.memory-card.matched .card-inner {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 9px;
    backface-visibility: hidden;
}

.card-front {
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at center, rgba(211,19,75,.25), transparent 48%),
        #0d0d0d;
}

.card-front::before {
    content: "✦";
    color: var(--ruby);
    font-family: "Cormorant Garamond", serif;
    font-size: 48px;
}

.card-front::after {
    content: "J";
    position: absolute;
    color: rgba(255,255,255,.07);
    font-family: "Cormorant Garamond", serif;
    font-size: 150px;
    line-height: 1;
}

.card-back {
    transform: rotateY(180deg);
    background: #111;
}

.card-back img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.memory-card.matched {
    border-color: rgba(211,19,75,.8);
    box-shadow: 0 0 22px rgba(211,19,75,.12);
}

.restart-button,
.result-actions button {
    margin-top: 25px;
    padding: 14px 22px;
    border: 1px solid var(--ruby);
    background: var(--ruby);
    color: white;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .15em;
    cursor: pointer;
}

.restart-button:hover,
.result-actions button:hover {
    background: #b80f40;
}

.result-panel {
    display: none;
    text-align: center;
}

.result-label {
    color: var(--ruby);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .24em;
}

.result-panel h2 {
    margin-top: 20px;
    font-family: "Cormorant Garamond", serif;
    font-size: clamp(65px, 9vw, 110px);
    font-weight: 500;
    line-height: .75;
}

.result-stats {
    margin: 55px auto 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    max-width: 600px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.result-stats div {
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.result-stats span {
    color: rgba(255,255,255,.35);
    font-size: 8px;
    letter-spacing: .18em;
}

.result-stats strong {
    color: var(--ruby);
    font-size: 18px;
}

.result-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
}

.result-actions button { margin-top: 25px; }

.result-actions a {
    margin-top: 25px;
    color: rgba(255,255,255,.5);
    text-decoration: none;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: .12em;
}

.result-actions a:hover { color: white; }

.memory-footer {
    margin-top: auto;
    padding: 30px 7%;
    display: flex;
    justify-content: space-between;
    border-top: 1px solid var(--line);
}

.memory-footer span {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
}

.memory-footer p {
    color: rgba(255,255,255,.3);
    font-size: 8px;
    letter-spacing: .18em;
}

@media (max-width: 700px) {
    .memory-nav {
        height: auto;
        padding: 22px 18px;
        flex-direction: column;
        gap: 22px;
    }

    .memory-nav nav {
        width: 100%;
        justify-content: space-between;
        gap: 7px;
    }

    .memory-nav nav a { font-size: 7px; }

    .memory-main {
        width: calc(100% - 30px);
        padding: 65px 0 75px;
    }

    .memory-heading h1 { font-size: 72px; }

    .game-panel,
    .result-panel {
        padding: 20px;
        border-radius: 14px;
    }

    .memory-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .game-top strong { font-size: 14px; }

    .result-stats {
        grid-template-columns: 1fr;
    }

    .result-stats div {
        border-bottom: 1px solid var(--line);
    }

    .result-actions {
        flex-direction: column;
        gap: 0;
    }

    .memory-footer { padding: 25px 20px; }
}
