/* =========================================================
   GAMESO — 2048
========================================================= */

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

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

    --primary: #6c5ce7;
    --primary-light: #8175ee;
    --accent: #00d4ff;

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

    --board: #111827;
    --empty: #1a2232;
}


/* =========================================================
   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.14),
            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.9);

    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);

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

    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(520px, 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);
}


/* =========================================================
   SCORE
========================================================= */

.game-top {
    display: grid;

    grid-template-columns: 1fr 1fr;

    gap: 10px;

    margin-bottom: 14px;
}

.score-box {
    padding: 10px 15px;

    text-align: center;

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

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

    border-radius: 12px;
}

.score-box span {
    display: block;

    color: var(--muted);

    font-size: 9px;

    font-weight: 800;

    letter-spacing: 1px;
}

.score-box strong {
    display: block;

    margin-top: 1px;

    color: white;

    font-size: 22px;

    line-height: 1.3;
}


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

.game-controls {
    display: flex;

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

    gap: 15px;

    margin-bottom: 15px;
}

.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 13px;

    color: white;

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

    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);
}


/* =========================================================
   2048 BOARD
========================================================= */

.game-board {
    width: min(440px, 100%);

    aspect-ratio: 1 / 1;

    margin: auto;

    padding: 9px;

    display: grid;

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

    gap: 9px;

    background:
        #0a0f1b;

    border:
        1px solid rgba(255, 255, 255, 0.08);

    border-radius: 18px;

    touch-action: none;

    user-select: none;
}


/* =========================================================
   EMPTY CELLS
========================================================= */

.cell {
    min-width: 0;
    min-height: 0;

    display: flex;

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

    background:
        var(--empty);

    border-radius: 12px;
}


/* =========================================================
   TILE
========================================================= */

.cell.tile {
    position: relative;

    color: white;

    font-size:
        clamp(24px, 6vw, 42px);

    font-weight: 900;

    line-height: 1;

    animation:
        tileAppear 0.15s ease;
}

@keyframes tileAppear {

    from {
        opacity: 0;

        transform:
            scale(0.75);
    }

    to {
        opacity: 1;

        transform:
            scale(1);
    }
}


/* =========================================================
   TILE COLORS
========================================================= */

.tile-2 {
    background: #26324a;
}

.tile-4 {
    background: #303e59;
}

.tile-8 {
    background: #4c43a8;
}

.tile-16 {
    background: #5b4ed1;
}

.tile-32 {
    background: #6c5ce7;
}

.tile-64 {
    background: #8175ee;
}

.tile-128 {
    background: #4f8ee8;

    font-size:
        clamp(21px, 5vw, 34px) !important;
}

.tile-256 {
    background: #3d9bd8;

    font-size:
        clamp(21px, 5vw, 34px) !important;
}

.tile-512 {
    background: #238fc0;

    font-size:
        clamp(21px, 5vw, 34px) !important;
}

.tile-1024 {
    background: #087aa9;

    font-size:
        clamp(17px, 4vw, 29px) !important;
}

.tile-2048 {
    background:
        linear-gradient(
            135deg,
            #00b8d9,
            #6c5ce7
        );

    box-shadow:
        0 0 28px rgba(0, 212, 255, 0.25);

    font-size:
        clamp(17px, 4vw, 29px) !important;
}

.tile-super {
    background:
        linear-gradient(
            135deg,
            #8175ee,
            #00d4ff
        );

    box-shadow:
        0 0 25px rgba(108, 92, 231, 0.25);

    font-size:
        clamp(15px, 3.5vw, 25px) !important;
}


/* =========================================================
   GAME 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);
}


/* =========================================================
   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;
}


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

@media (max-width: 700px) {

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

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

    .game-box {
        padding: 11px;

        border-radius: 17px;
    }

    .game-board {
        gap: 6px;

        padding: 6px;

        border-radius: 15px;
    }

    .cell {
        border-radius: 9px;
    }

    .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;
    }
}


/* =========================================================
   SMALL 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-board {
        gap: 5px;

        padding: 5px;
    }

    .cell {
        border-radius: 7px;
    }

    .score-box strong {
        font-size: 19px;
    }
}


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

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

    outline-offset: 3px;
}
