/* =========================================================
   DINO RUSH — STYLE
   Cloudflare Pages / Telegram Mini App
========================================================= */

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

    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

:root {
    --bg: #06090b;
    --bg-soft: #0b1013;

    --panel: rgba(14, 19, 23, 0.94);
    --panel-soft: rgba(255, 255, 255, 0.045);

    --text: #f5f7f8;
    --muted: #7f8993;

    --green: #7cf28d;
    --green-dark: #38c95d;

    --gold: #ffd45a;
    --red: #ff5870;

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

    --shadow:
        0 30px 100px rgba(0, 0, 0, 0.65);
}

html,
body {
    width: 100%;
    height: 100%;

    overflow: hidden;

    background: var(--bg);
    color: var(--text);

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

body {
    min-height: 100dvh;

    overscroll-behavior: none;
}

button,
a {
    font: inherit;
}

button {
    border: 0;
    outline: none;
}

a {
    color: inherit;
}


/* =========================================================
   APP
========================================================= */

.app {
    position: relative;

    width: 100%;
    height: 100dvh;

    max-width: 620px;

    margin: 0 auto;

    overflow: hidden;

    background:
        radial-gradient(
            circle at 50% -15%,
            rgba(75, 229, 104, 0.10),
            transparent 35%
        ),
        linear-gradient(
            180deg,
            #080c0f 0%,
            #050708 100%
        );
}


/* =========================================================
   TOP BAR
========================================================= */

.topbar {
    position: absolute;

    z-index: 30;

    top: 0;
    left: 0;

    width: 100%;

    padding:
        max(14px, env(safe-area-inset-top))
        16px
        0;

    display: flex;

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

    pointer-events: none;
}


/* Brand */

.brand {
    color: #ffffff;

    font-size: 20px;
    line-height: 1;

    font-weight: 1000;

    letter-spacing: -1.2px;

    text-shadow:
        0 4px 20px rgba(0, 0, 0, 0.35);
}

.brand span {
    color: var(--green);
}


/* Telegram user */

.telegram-user {
    display: flex;

    align-items: center;

    gap: 8px;

    min-height: 38px;

    padding: 4px 9px 4px 4px;

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

    border-radius: 20px;

    background:
        rgba(10, 14, 17, 0.78);

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

    pointer-events: auto;
}

.avatar {
    width: 30px;
    height: 30px;

    flex: 0 0 30px;

    border-radius: 50%;

    object-fit: cover;

    background:
        linear-gradient(
            135deg,
            #1c3524,
            #5de477
        );
}

.avatar-fallback {
    display: flex;

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

    color: #071109;

    font-size: 11px;
    font-weight: 1000;
}

.username {
    display: block;

    max-width: 105px;

    overflow: hidden;

    white-space: nowrap;
    text-overflow: ellipsis;

    color: #eef2f3;

    font-size: 11px;
    font-weight: 850;
}


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

.score-panel {
    position: absolute;

    z-index: 20;

    top: 74px;
    left: 50%;

    transform: translateX(-50%);

    width: max-content;

    text-align: center;

    pointer-events: none;
}

.score-label {
    color: var(--muted);

    font-size: 8px;
    line-height: 1;

    font-weight: 900;

    letter-spacing: 2px;
}

.score {
    margin-top: 5px;

    color: #ffffff;

    font-size: 30px;
    line-height: 1;

    font-weight: 1000;

    font-variant-numeric: tabular-nums;

    letter-spacing: -1px;

    text-shadow:
        0 0 28px rgba(124, 242, 141, 0.12);
}

.best {
    margin-top: 6px;

    color: #68737e;

    font-size: 9px;
    line-height: 1;

    font-weight: 800;

    font-variant-numeric: tabular-nums;
}


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

#gameCanvas {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;

    display: block;

    touch-action: none;
}


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

.game-controls {
    position: absolute;

    z-index: 25;

    left: 0;
    bottom: 0;

    width: 100%;

    padding:
        0
        16px
        max(17px, env(safe-area-inset-bottom));

    display: flex;

    justify-content: center;

    pointer-events: none;
}

.jump-button {
    width: min(240px, 75vw);

    min-height: 49px;

    padding: 0 22px;

    border:
        1px solid rgba(124, 242, 141, 0.16);

    border-radius: 16px;

    background:
        linear-gradient(
            135deg,
            rgba(51, 187, 78, 0.22),
            rgba(14, 26, 19, 0.88)
        );

    color: #eaffed;

    font-size: 11px;
    font-weight: 950;

    letter-spacing: 0.8px;

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

    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.25);

    pointer-events: auto;

    cursor: pointer;

    touch-action: manipulation;

    transition:
        transform 0.12s ease,
        background 0.12s ease;
}

.jump-button:active {
    transform: scale(0.96);

    background:
        linear-gradient(
            135deg,
            rgba(61, 211, 91, 0.30),
            rgba(14, 26, 19, 0.95)
        );
}


/* =========================================================
   OVERLAY
========================================================= */

.overlay {
    position: absolute;

    z-index: 100;

    inset: 0;

    display: flex;

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

    padding:
        25px
        18px
        max(25px, env(safe-area-inset-bottom));

    background:
        rgba(2, 5, 6, 0.58);

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

    opacity: 1;

    visibility: visible;

    transition:
        opacity 0.2s ease,
        visibility 0.2s ease;
}

.overlay.hidden {
    opacity: 0;

    visibility: hidden;

    pointer-events: none;
}


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

.game-card {
    width: min(390px, 100%);

    padding:
        28px
        22px
        22px;

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

    border-radius: 28px;

    background:
        radial-gradient(
            circle at 50% 0%,
            rgba(87, 232, 108, 0.11),
            transparent 47%
        ),
        rgba(11, 15, 18, 0.97);

    box-shadow: var(--shadow);

    text-align: center;
}


/* =========================================================
   START / GAME OVER ICON
========================================================= */

.dino-emoji,
.game-over-icon {
    width: 72px;
    height: 72px;

    margin: 0 auto 8px;

    display: flex;

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

    border-radius: 22px;

    background:
        rgba(124, 242, 141, 0.055);

    font-size: 48px;

    filter:
        drop-shadow(
            0 12px 25px
            rgba(124, 242, 141, 0.13)
        );
}

.game-over-icon {
    background:
        rgba(255, 88, 112, 0.055);

    filter:
        drop-shadow(
            0 12px 25px
            rgba(255, 88, 112, 0.10)
        );
}


/* =========================================================
   TITLES
========================================================= */

.game-title {
    color: #ffffff;

    font-size: 34px;
    line-height: 1;

    font-weight: 1000;

    letter-spacing: -2px;
}

.game-over-title {
    color: var(--red);

    font-size: 31px;
    line-height: 1;

    font-weight: 1000;

    letter-spacing: -1.7px;
}

.game-description {
    max-width: 290px;

    margin: 11px auto 0;

    color: var(--muted);

    font-size: 11px;
    line-height: 1.55;

    font-weight: 600;
}


/* =========================================================
   PERSONAL BEST
========================================================= */

.personal-best {
    margin-top: 20px;

    display: flex;

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

    gap: 10px;
}

.personal-best span {
    color: #69747e;

    font-size: 8px;

    font-weight: 900;

    letter-spacing: 1.4px;
}

.personal-best strong {
    color: #ffffff;

    font-size: 18px;

    font-weight: 1000;

    font-variant-numeric: tabular-nums;
}


/* =========================================================
   BUTTONS
========================================================= */

.primary-button,
.secondary-button {
    width: 100%;

    min-height: 50px;

    border-radius: 15px;

    font-size: 12px;

    font-weight: 950;

    cursor: pointer;

    touch-action: manipulation;

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

.primary-button:active,
.secondary-button:active {
    transform: scale(0.97);
}


/* Primary */

.primary-button {
    margin-top: 22px;

    background:
        linear-gradient(
            135deg,
            var(--green-dark),
            var(--green)
        );

    color: #061008;

    box-shadow:
        0 12px 35px
        rgba(57, 207, 96, 0.20);
}

.primary-button:hover {
    filter: brightness(1.06);
}


/* =========================================================
   RESULTS
========================================================= */

.results {
    display: flex;

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

    gap: 10px;

    margin-top: 21px;
}

.result-box {
    flex: 1;

    min-width: 0;

    padding: 13px 8px;

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

    border-radius: 14px;

    background:
        rgba(255, 255, 255, 0.025);
}

.result-box span {
    display: block;

    color: #6d7781;

    font-size: 8px;

    font-weight: 900;

    letter-spacing: 1.2px;
}

.result-box strong {
    display: block;

    margin-top: 4px;

    color: #ffffff;

    font-size: 21px;

    line-height: 1;

    font-weight: 1000;

    font-variant-numeric: tabular-nums;
}


/* =========================================================
   GAME OVER ACTIONS
========================================================= */

.game-over-actions {
    display: flex;

    flex-direction: column;

    gap: 9px;

    margin-top: 14px;
}

.game-over-actions .primary-button {
    margin-top: 0;
}

.secondary-button {
    border:
        1px solid rgba(255, 255, 255, 0.09);

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

    color: #f3f6f7;
}

.secondary-button:hover {
    background:
        rgba(255, 255, 255, 0.075);
}


/* =========================================================
   TRUEGEM PROMOTION
========================================================= */

.promotion {
    display: flex;

    align-items: center;

    gap: 10px;

    width: 100%;

    margin-top: 18px;

    padding: 12px;

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

    border-radius: 16px;

    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.045),
            rgba(255, 255, 255, 0.018)
        );

    text-align: left;

    text-decoration: none;

    transition:
        transform 0.12s ease,
        background 0.12s ease;
}

.promotion:active {
    transform: scale(0.98);
}

.promotion:hover {
    background:
        linear-gradient(
            135deg,
            rgba(255, 255, 255, 0.065),
            rgba(255, 255, 255, 0.025)
        );
}

.promotion-icon {
    width: 39px;
    height: 39px;

    flex: 0 0 39px;

    display: flex;

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

    border-radius: 11px;

    background:
        linear-gradient(
            135deg,
            #ffe38a,
            #d89b2c
        );

    color: #171006;

    font-size: 18px;

    box-shadow:
        0 7px 20px
        rgba(218, 158, 45, 0.15);
}

.promotion-content {
    flex: 1;

    min-width: 0;
}

.promotion-title {
    color: #ffffff;

    font-size: 11px;

    font-weight: 1000;
}

.promotion-text {
    margin-top: 3px;

    color: #78838d;

    font-size: 9px;

    line-height: 1.35;
}

.promotion-arrow {
    color: #78838d;

    font-size: 22px;

    line-height: 1;
}


/* =========================================================
   TELEGRAM REQUIRED
========================================================= */

.telegram-required {
    position: fixed;

    z-index: 9999;

    inset: 0;

    display: flex;

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

    padding: 25px;

    background:
        #050708;

    text-align: center;
}

.telegram-required.hidden {
    display: none;
}

.telegram-required-card {
    width: min(370px, 100%);

    padding: 30px 23px;

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

    border-radius: 27px;

    background:
        rgba(13, 18, 22, 0.97);

    box-shadow: var(--shadow);
}

.telegram-required-icon {
    margin-bottom: 12px;

    font-size: 53px;
}

.telegram-required-card h2 {
    color: #ffffff;

    font-size: 27px;

    font-weight: 1000;

    letter-spacing: -1px;
}

.telegram-required-card p {
    margin-top: 10px;

    color: var(--muted);

    font-size: 12px;

    line-height: 1.55;
}

.telegram-required-card .small-text {
    margin-top: 5px;

    font-size: 10px;

    color: #59636d;
}

.telegram-button {
    display: flex;

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

    min-height: 48px;

    margin-top: 21px;

    border-radius: 14px;

    background:
        linear-gradient(
            135deg,
            var(--green-dark),
            var(--green)
        );

    color: #061008;

    font-size: 11px;

    font-weight: 950;

    text-decoration: none;
}


/* =========================================================
   TOAST
========================================================= */

.toast {
    position: absolute;

    z-index: 300;

    left: 50%;
    bottom: calc(
        max(85px, env(safe-area-inset-bottom) + 65px)
    );

    transform:
        translate(-50%, 15px);

    width: max-content;

    max-width: calc(100% - 35px);

    padding: 10px 15px;

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

    border-radius: 12px;

    background:
        rgba(14, 19, 23, 0.94);

    color: #ffffff;

    font-size: 10px;

    font-weight: 850;

    box-shadow:
        0 15px 40px
        rgba(0, 0, 0, 0.35);

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

    opacity: 0;

    visibility: hidden;

    pointer-events: none;

    transition:
        opacity 0.18s ease,
        transform 0.18s ease,
        visibility 0.18s ease;
}

.toast.show {
    opacity: 1;

    visibility: visible;

    transform:
        translate(-50%, 0);
}


/* =========================================================
   SMALL DEVICES
========================================================= */

@media (max-width: 380px) {

    .brand {
        font-size: 18px;
    }

    .username {
        max-width: 80px;
    }

    .score {
        font-size: 27px;
    }

    .game-card {
        padding:
            23px
            18px
            19px;

        border-radius: 24px;
    }

    .dino-emoji,
    .game-over-icon {
        width: 62px;
        height: 62px;

        font-size: 42px;
    }

    .game-title {
        font-size: 30px;
    }

}


/* =========================================================
   VERY SHORT SCREENS
========================================================= */

@media (max-height: 650px) {

    .score-panel {
        top: 66px;
    }

    .game-card {
        padding-top: 18px;
        padding-bottom: 17px;
    }

    .dino-emoji,
    .game-over-icon {
        width: 54px;
        height: 54px;

        margin-bottom: 5px;

        font-size: 37px;
    }

    .game-title {
        font-size: 28px;
    }

    .game-description {
        margin-top: 7px;
    }

    .personal-best {
        margin-top: 13px;
    }

    .primary-button {
        margin-top: 14px;
    }

    .promotion {
        margin-top: 11px;
    }

}


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

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;

        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }

}


/* =========================================================
   DESKTOP / LARGE SCREEN
========================================================= */

@media (min-width: 700px) {

    body {
        display: flex;

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

        background:
            #020405;
    }

    .app {
        height: 100dvh;

        max-height: 900px;

        border-left:
            1px solid rgba(255, 255, 255, 0.025);

        border-right:
            1px solid rgba(255, 255, 255, 0.025);
    }

}