﻿* {
    box-sizing: border-box;
}

html,
body {
    overscroll-behavior: none;
}

body {
    margin: 0;

    min-height: 100vh;

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

    font-family: Arial, sans-serif;

    background:
        radial-gradient(
            circle at top,
            #27345c,
            #11172b 60%,
            #080c18
        );

    color: white;

    user-select: none;
}

.hidden {
    display: none !important;
}


/* ============================================================
   MENU
   ============================================================ */

.screen {
    width: 100%;

    min-height: 100vh;

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

    padding: 20px;
}

.menu-card {
    width: min(94vw, 520px);

    padding: 28px;

    border-radius: 24px;

    background:
        rgba(20, 27, 50, 0.97);

    box-shadow:
        0 20px 60px
        rgba(0, 0, 0, 0.55);
}

.menu-card h1 {
    margin:
        0
        0
        6px
        0;

    text-align: center;

    font-size: 38px;
}

.menu-subtitle {
    margin-bottom: 22px;

    text-align: center;

    font-size: 19px;

    color: #b9c4ef;
}

.level-list {
    display: grid;

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

    gap: 10px;

    margin-bottom: 18px;
}

.level-button {
    position: relative;

    min-height: 100px;

    padding: 13px;

    border: 2px solid transparent;

    border-radius: 16px;

    cursor: pointer;

    color: white;

    background: #25345f;

    transition:
        transform 0.12s ease,
        filter 0.12s ease,
        border 0.12s ease;
}

.level-button:hover {
    transform: scale(1.03);

    filter: brightness(1.12);
}

.level-button.completed {
    border-color: #72e18e;

    background: #244f42;
}

.level-button.locked {
    opacity: 0.48;

    cursor: not-allowed;

    background: #20263a;
}

.level-number {
    margin-bottom: 6px;

    font-size: 22px;
    font-weight: bold;
}

.level-info {
    font-size: 14px;

    line-height: 1.45;

    color: #cbd3f5;
}

.level-status {
    margin-top: 7px;

    font-size: 16px;
}


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

.game {
    width: min(96vw, 650px);

    padding: 20px;

    border-radius: 24px;

    background:
        rgba(20, 27, 50, 0.97);

    box-shadow:
        0 20px 60px
        rgba(0, 0, 0, 0.55);
}

.game-header {
    display: grid;

    grid-template-columns:
        45px
        1fr
        45px;

    align-items: center;

    margin-bottom: 15px;
}

.game-header h1 {
    margin: 0;

    text-align: center;

    font-size: 30px;
}

.back-button {
    width: 42px;
    height: 42px;

    padding: 0;

    border: none;

    border-radius: 12px;

    cursor: pointer;

    font-size: 25px;

    color: white;

    background: #36466f;
}

.header-space {
    width: 42px;
}

.stats {
    display: grid;

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

    gap: 8px;

    margin-bottom: 15px;
}

.stat {
    padding: 10px 5px;

    text-align: center;

    border-radius: 14px;

    background: #171f39;
}

.stat-title {
    margin-bottom: 4px;

    font-size: 14px;

    color: #aeb9e4;
}

.stat-value {
    font-size: 25px;
    font-weight: bold;
}

#score {
    color: #ffd54a;
}

#moves {
    color: #79dcff;
}

#goal {
    color: #8cff9c;
}

#board {
    display: grid;

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

    gap: 5px;

    width: 100%;

    aspect-ratio: 1 / 1;

    padding: 7px;

    border-radius: 18px;

    background: #090e1c;

    touch-action: none;
}

.tile {
    position: relative;

    display: flex;

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

    min-width: 0;
    min-height: 0;

    overflow: hidden;

    border:
        3px solid transparent;

    border-radius: 14px;

    cursor: grab;

    background: #1c2645;

    transition:
        transform 0.16s ease,
        opacity 0.20s ease,
        border 0.14s ease,
        background 0.14s ease,
        box-shadow 0.15s ease;

    touch-action: none;
}

.tile:hover {
    background: #28365f;
}

.tile:active {
    cursor: grabbing;
}

.tile.selected {
    border-color: white;

    transform: scale(1.08);

    background: #354875;

    box-shadow:
        0 0 16px
        rgba(255, 255, 255, 0.7);
}

.tile.matched {
    opacity: 0;

    transform:
        scale(0.15)
        rotate(15deg);
}

.gem-icon {
    position: relative;

    z-index: 1;

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

    line-height: 1;
}

.special-mark {
    position: absolute;

    z-index: 3;

    right: 2px;
    bottom: 1px;

    display: flex;

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

    min-width: 24px;
    min-height: 24px;

    padding: 1px 3px;

    border-radius: 8px;

    font-size:
        clamp(
            15px,
            3vw,
            23px
        );

    font-weight: 900;

    color: white;

    background:
        rgba(0, 0, 0, 0.65);
}

.tile.special-rocket {
    box-shadow:
        inset 0 0 17px
        rgba(255, 230, 100, 0.60),

        0 0 10px
        rgba(255, 210, 70, 0.35);
}

.tile.special-bomb {
    box-shadow:
        inset 0 0 20px
        rgba(255, 120, 60, 0.75),

        0 0 12px
        rgba(255, 90, 40, 0.45);
}

.tile.special-rainbow {
    background:
        linear-gradient(
            135deg,
            #572cad,
            #285dd9,
            #22a86c,
            #d0aa28,
            #d74a4a
        );

    box-shadow:
        inset 0 0 20px
        rgba(255, 255, 255, 0.38),

        0 0 15px
        rgba(255, 255, 255, 0.40);
}

#message {
    min-height: 32px;

    margin-top: 13px;

    text-align: center;

    font-size: 19px;

    color: #cbd3f5;
}

button {
    font-family: inherit;
}

.restart-button,
.secondary-button,
#resultButton {
    width: 100%;

    border: none;

    border-radius: 13px;

    padding: 12px;

    font-size: 16px;
    font-weight: bold;

    cursor: pointer;

    color: white;

    background: #5269d9;
}

.restart-button {
    margin-top: 8px;
}

.secondary-button {
    background: #343e60;
}

button:hover {
    filter: brightness(1.12);
}


/* ============================================================
   RESULT
   ============================================================ */

.overlay {
    position: fixed;

    z-index: 1000;

    inset: 0;

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

    padding: 20px;

    background:
        rgba(5, 8, 18, 0.82);

    backdrop-filter:
        blur(8px);
}

.result-window {
    width: min(92vw, 420px);

    padding: 30px 24px;

    text-align: center;

    border-radius: 24px;

    background: #171f39;

    box-shadow:
        0 25px 80px
        rgba(0, 0, 0, 0.65);
}

.result-icon {
    margin-bottom: 8px;

    font-size: 70px;
}

.result-window h2 {
    margin:
        0
        0
        12px
        0;

    font-size: 35px;
}

.result-text {
    margin-bottom: 22px;

    font-size: 19px;

    line-height: 1.5;

    color: #d7dcf4;
}

.result-menu-button {
    margin-top: 10px;
}


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

@media (max-width: 500px) {

    body {
        align-items: flex-start;
    }

    .game {
        min-height: 100vh;

        padding: 11px;

        border-radius: 0;
    }

    .screen {
        align-items: flex-start;

        padding: 12px;
    }

    .menu-card {
        margin-top: 20px;

        padding: 18px;
    }

    .menu-card h1 {
        font-size: 32px;
    }

    .game-header h1 {
        font-size: 25px;
    }

    .stat-value {
        font-size: 21px;
    }

    #board {
        gap: 3px;

        padding: 4px;
    }

    .tile {
        border-radius: 9px;
    }

    .special-mark {
        min-width: 19px;
        min-height: 19px;

        border-radius: 6px;
    }
}

/* ============================================================
   TELEGRAM MINI APP
   ============================================================ */

.telegram-mode-badge {
    position: fixed;

    z-index: 5000;

    left: 8px;
    bottom: 8px;

    padding: 5px 9px;

    border-radius: 10px;

    font-size: 11px;

    color: #aab4d8;

    background:
        rgba(
            10,
            15,
            30,
            0.82
        );

    pointer-events: none;
}

.telegram-mode-badge.telegram-connected {
    color: #a8ffb5;

    border:
        1px solid
        rgba(
            100,
            255,
            140,
            0.25
        );
}
