/* =========================================
   GAMESO MEMORY GAME
========================================= */

:root {
    --bg: #080b14;
    --card: #121827;
    --card-hover: #171f31;

    --text: #ffffff;
    --muted: #9aa3b5;

    --primary: #6c5ce7;
    --accent: #00d4ff;

    --border: rgba(255, 255, 255, 0.08);

    --memory-card: #171f35;
}


/* =========================================
   RESET
========================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;

    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Arial,
        sans-serif;

    color: var(--text);

    background:
        radial-gradient(
            circle at 50% 0%,
            rgba(108, 92, 231, 0.15),
            transparent 38%
        ),
        var(--bg);

    line-height: 1.6;

    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font: inherit;
}


/* =========================================
   HEADER
========================================= */

.game-header {
    position: sticky;
    top: 0;
    z-index: 100;

    height: 70px;

    background:
        rgba(8, 11, 20, 0.90);

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    border-bottom:
        1px solid var(--border);
}

.header-inner {
    width:
        min(1100px, calc(100% - 32px));

    height: 100%;

    margin: auto;

    display: flex;

    align-items: center;
    justify-content: space-between;
}


/* =========================================
   LOGO
========================================= */

.logo {
    display: flex;

    align-items: center;

    gap: 9px;

    font-size: 20px;

    font-weight: 800;
}

.logo span {
    width: 35px;
    height: 35px;

    display: grid;
    place-items: center;

    border-radius: 10px;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            var(--accent)
        );

    font-size: 18px;
}

.logo strong {
    background:
        linear-gradient(
            90deg,
            #ffffff,
            #bdb9ff
        );

    -webkit-background-clip: text;
    background-clip: text;

    -webkit-text-fill-color: transparent;
}


/* =========================================
   BACK BUTTON
========================================= */

.back-button {
    min-height: 40px;

    padding: 0 15px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    color: var(--muted);

    background:
        rgba(255, 255, 255, 0.03);

    border:
        1px solid var(--border);

    border-radius: 10px;

    font-size: 13px;

    font-weight: 600;

    transition: 0.25s ease;
}

.back-button:hover {
    color: white;

    background:
        rgba(255, 255, 255, 0.07);

    transform: translateX(-2px);
}


/* =========================================
   MAIN
========================================= */

.game-page {
    padding: 55px 0 80px;
}

.game-container {
    width:
        min(900px, calc(100% - 32px));

    margin: auto;
}


/* =========================================
   HEADING
========================================= */

.game-heading {
    text-align: center;

    margin-bottom: 30px;
}

.game-label {
    display: inline-block;

    margin-bottom: 10px;

    color: #9b93ff;

    font-size: 11px;

    font-weight: 800;

    letter-spacing: 1px;
}

.game-heading h1 {
    font-size:
        clamp(32px, 5vw, 48px);

    line-height: 1.1;

    letter-spacing: -1.5px;

    font-weight: 800;
}

.game-heading p {
    max-width: 620px;

    margin: 12px auto 0;

    color: var(--muted);

    font-size: 14px;
}


/* =========================================
   GAME BOX
========================================= */

.game-box {
    width:
        min(560px, 100%);

    margin: auto;

    padding: 18px;

    background:
        linear-gradient(
            145deg,
            #141b2b,
            #0e1422
        );

    border:
        1px solid var(--border);

    border-radius: 22px;

    box-shadow:
        0 25px 70px rgba(0, 0, 0, 0.35);
}


/* =========================================
   STATS
========================================= */

.game-stats {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 10px;

    margin-bottom: 15px;
}

.stat-box {
    padding: 10px;

    text-align: center;

    background:
        rgba(255, 255, 255, 0.04);

    border:
        1px solid var(--border);

    border-radius: 12px;
}

.stat-box span {
    display: block;

    color: var(--muted);

    font-size: 9px;

    font-weight: 800;

    letter-spacing: 1px;
}

.stat-box strong {
    display: block;

    margin-top: 1px;

    color: white;

    font-size: 20px;

    line-height: 1.3;
}


/* =========================================
   CONTROLS
========================================= */

.game-controls {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;

    margin-bottom: 16px;
}

.game-tip {
    display: flex;

    flex-direction: column;

    gap: 2px;
}

.game-tip strong {
    color: white;

    font-size: 12px;
}

.game-tip span {
    color: var(--muted);

    font-size: 10px;
}

.new-game-button {
    flex-shrink: 0;

    min-height: 40px;

    padding: 0 14px;

    color: white;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            #5144d7
        );

    border: none;

    border-radius: 10px;

    font-size: 11px;

    font-weight: 700;

    cursor: pointer;

    box-shadow:
        0 8px 20px rgba(108, 92, 231, 0.2);

    transition: 0.25s ease;
}

.new-game-button:hover {
    transform: translateY(-2px);

    box-shadow:
        0 12px 25px rgba(108, 92, 231, 0.3);
}

.new-game-button:active {
    transform: translateY(0);
}


/* =========================================
   MEMORY BOARD
========================================= */

.memory-board {
    width:
        min(500px, 100%);

    margin: auto;

    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 10px;

    perspective: 1000px;

    user-select: none;
}


/* =========================================
   MEMORY CARD
========================================= */

.memory-card {
    position: relative;

    aspect-ratio: 1 / 1;

    border: none;

    padding: 0;

    background: transparent;

    cursor: pointer;

    perspective: 900px;
}

.card-inner {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    transition:
        transform 0.45s cubic-bezier(
            0.4,
            0.2,
            0.2,
            1
        );

    transform-style: preserve-3d;
}

.memory-card.flipped .card-inner,
.memory-card.matched .card-inner {
    transform: rotateY(180deg);
}


/* =========================================
   CARD FRONT + BACK
========================================= */

.card-front,
.card-back {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    display: flex;

    align-items: center;
    justify-content: center;

    border-radius: 15px;

    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;

    border:
        1px solid var(--border);
}


/* =========================================
   CARD BACK
========================================= */

.card-back {
    background:
        linear-gradient(
            145deg,
            #1c2540,
            #101729
        );

    box-shadow:
        0 8px 20px rgba(0, 0, 0, 0.18);

    transition: 0.2s ease;
}

.memory-card:hover .card-back {
    border-color:
        rgba(108, 92, 231, 0.45);

    box-shadow:
        0 10px 25px rgba(108, 92, 231, 0.14);
}

.card-back::before {
    content: "✦";

    width: 44px;
    height: 44px;

    display: grid;
    place-items: center;

    border-radius: 13px;

    color: #a69fff;

    background:
        rgba(108, 92, 231, 0.10);

    border:
        1px solid rgba(108, 92, 231, 0.18);

    font-size: 22px;
}


/* =========================================
   CARD FRONT
========================================= */

.card-front {
    transform: rotateY(180deg);

    background:
        linear-gradient(
            145deg,
            #202a44,
            #141c30
        );

    box-shadow:
        0 8px 22px rgba(0, 0, 0, 0.2);
}

.card-front span {
    font-size:
        clamp(28px, 7vw, 44px);

    line-height: 1;

    transform:
        translateZ(1px);
}


/* =========================================
   MATCHED
========================================= */

.memory-card.matched {
    pointer-events: none;
}

.memory-card.matched .card-front {
    border-color:
        rgba(0, 212, 255, 0.45);

    box-shadow:
        0 0 22px rgba(0, 212, 255, 0.14);

    animation:
        matchedPulse 0.45s ease;
}

@keyframes matchedPulse {

    0% {
        transform: rotateY(180deg) scale(1);
    }

    50% {
        transform: rotateY(180deg) scale(1.06);
    }

    100% {
        transform: rotateY(180deg) scale(1);
    }
}


/* =========================================
   WIN MESSAGE
========================================= */

.game-message {
    min-height: 58px;

    margin-top: 14px;

    display: flex;

    align-items: center;
    justify-content: center;

    text-align: center;

    color: white;

    font-size: 14px;

    font-weight: 600;
}

.game-message:empty {
    min-height: 5px;
}

.game-message strong {
    color: var(--accent);
}

.game-message small {
    color: var(--muted);

    font-size: 11px;
}


/* =========================================
   INFO
========================================= */

.game-info-section {
    max-width: 760px;

    margin: 65px auto 0;
}

.game-info-section h2,
.related-section h2 {
    margin-bottom: 13px;

    color: white;

    font-size: 23px;

    line-height: 1.3;

    letter-spacing: -0.5px;
}

.game-info-section h2:not(:first-child) {
    margin-top: 38px;
}

.game-info-section p {
    margin-bottom: 12px;

    color: var(--muted);

    font-size: 14px;

    line-height: 1.8;
}

.game-info-section ul {
    padding-left: 20px;

    color: var(--muted);

    font-size: 14px;

    line-height: 2;
}


/* =========================================
   RELATED GAMES
========================================= */

.related-section {
    max-width: 760px;

    margin: 65px auto 0;
}

.related-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 12px;
}

.related-card {
    min-height: 100px;

    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 7px;

    background: var(--card);

    border:
        1px solid var(--border);

    border-radius: 14px;

    transition: 0.25s ease;
}

.related-card:hover {
    transform: translateY(-3px);

    background: var(--card-hover);

    border-color:
        rgba(108, 92, 231, 0.35);
}

.related-card span {
    font-size: 30px;
}

.related-card strong {
    color: white;

    font-size: 12px;
}


/* =========================================
   FOOTER
========================================= */

footer {
    padding: 22px 20px;

    text-align: center;

    background: #060810;

    border-top:
        1px solid var(--border);

    color: #697284;

    font-size: 11px;
}


/* =========================================
   TABLET
========================================= */

@media (max-width: 700px) {

    .game-page {
        padding: 40px 0 60px;
    }

    .game-heading h1 {
        font-size: 34px;
    }

    .game-box {
        padding: 11px;

        border-radius: 17px;
    }

    .memory-board {
        gap: 7px;
    }

    .card-front,
    .card-back {
        border-radius: 11px;
    }

    .game-controls {
        align-items: stretch;

        flex-direction: column;
    }

    .new-game-button {
        width: 100%;
    }

    .game-info-section {
        margin-top: 50px;
    }

    .related-section {
        margin-top: 50px;
    }

    .related-grid {
        grid-template-columns: 1fr;
    }

    .related-card {
        min-height: 70px;

        flex-direction: row;

        justify-content: flex-start;

        padding: 0 18px;
    }

    .related-card span {
        font-size: 25px;
    }
}


/* =========================================
   MOBILE
========================================= */

@media (max-width: 420px) {

    .game-header {
        height: 62px;
    }

    .header-inner {
        width:
            calc(100% - 24px);
    }

    .logo {
        font-size: 18px;
    }

    .logo span {
        width: 32px;
        height: 32px;

        font-size: 16px;
    }

    .back-button {
        min-height: 36px;

        padding: 0 10px;

        font-size: 11px;
    }

    .game-container {
        width:
            calc(100% - 20px);
    }

    .game-heading h1 {
        font-size: 29px;
    }

    .game-heading p {
        font-size: 12px;
    }

    .game-stats {
        gap: 6px;
    }

    .stat-box {
        padding: 8px 5px;
    }

    .stat-box strong {
        font-size: 17px;
    }

    .memory-board {
        gap: 5px;
    }

    .card-front,
    .card-back {
        border-radius: 8px;
    }

    .card-back::before {
        width: 30px;
        height: 30px;

        border-radius: 9px;

        font-size: 16px;
    }

    .card-front span {
        font-size: 28px;
    }

    .game-info-section h2,
    .related-section h2 {
        font-size: 20px;
    }

    .game-info-section p,
    .game-info-section ul {
        font-size: 13px;
    }
}


/* =========================================
   ACCESSIBILITY
========================================= */

button:focus-visible,
a:focus-visible {
    outline:
        2px solid var(--accent);

    outline-offset: 3px;
}
