:root {
    --bg: #0b0f14;
    --card: #121923;
    --text: #eef2f6;
    --muted: #9fb0c3;
    --accent: #7dd3fc;
    --ok: #34d399;
    --warn: #fbbf24;
    --line: #1d2736;
    --app-max-width: 896px;
    --app-height: 100dvh;
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --content-width: min(100vw, var(--app-max-width));
    --main-art-width: min(100vw, var(--app-max-width));
    --nav-height: clamp(72px, calc((var(--content-width) - 8px) * 0.205), 156px);
    --button-text-panel-bg: rgba(255, 226, 154, 0.74);
    --button-text-panel-border: rgba(91, 36, 48, 0.36);
    --button-text-panel-glow: rgba(74, 25, 41, 0.24);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    height: 100%;
    height: var(--app-height, 100dvh);
    min-height: 100svh;
    min-height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    width: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    position: fixed;
    inset: 0;
    margin: 0;
    background: #344760;
    color: var(--text);
    font-family: "Inter", system-ui, Arial, sans-serif;
    height: var(--app-height, 100dvh);
    min-height: 100svh;
    min-height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    overflow: hidden;
    letter-spacing: 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

img,
button,
.btn-icon,
.bmp-glyph,
.balance-digit,
.energy-digit,
.upgrades-skin,
.withdraw-skin,
.referral-skin,
.tasks-skin,
.upg-slot,
.wth-slot,
.ref-slot,
.task-btn {
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

body:not(.app-loaded) {
    overflow: hidden;
}

.loading-screen {
    position: fixed;
    inset: 0;
    z-index: 5000;
    background: #000;
    min-height: 100svh;
    min-height: var(--app-height, 100dvh);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    pointer-events: auto;
    overflow: hidden;
}

.loading-gif {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 50%;
    image-rendering: auto;
}

body.app-loaded .loading-screen {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app {
    opacity: 0;
    transition: opacity 0.3s ease;
}

body.app-loaded .app {
    opacity: 1;
}

.app {
    width: 100%;
    max-width: var(--app-max-width);
    margin: 0 auto;
    height: var(--app-height, 100dvh);
    min-height: 100svh;
    min-height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    padding: 0 0 calc(var(--nav-height) + var(--app-safe-bottom) + 10px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: transparent;
}

@media (min-width: 521px) {
    .app {
        padding-bottom: calc(var(--nav-height) + var(--app-safe-bottom) + 10px);
    }
}

.top {
    width: 100%;
    position: relative;
    z-index: 10;
    padding: calc(max(var(--app-safe-top), 0px) + clamp(4px, 1dvh, 10px)) 0 0;
    border-top: 0;
    background: transparent;
    backdrop-filter: none;
    filter: none;
}

.top::after {
    display: none;
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 8px;
    min-height: 8px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 12, 18, .9);
    backdrop-filter: blur(6px);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.bottom-bar {
    padding: 0;
    margin-top: 0;
    height: 8px;
    min-height: 8px;
    border-top: none;
    border-bottom: 1px solid var(--line);
}

.balance-pill {
    background-image: url('/images/balance_frame.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    border-radius: 0;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-weight: 800;
    font-size: 22px;
    image-rendering: pixelated;
    width: 100%;
    height: calc((var(--content-width) / 4) * 0.8);
    max-height: calc((var(--app-max-width) / 4) * 0.8);
    box-sizing: border-box;
    position: relative;
    z-index: 10;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.balance-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
    image-rendering: pixelated;
    flex-shrink: 0;
    margin-top: -2px;
}

#balance {
    display: inline-flex;
    align-items: center;
    gap: 0px;
}

.balance-digit {
    display: inline-block;
    width: 40px;
    height: 40px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    flex-shrink: 0;
    vertical-align: middle;
    transition: opacity 0.35s ease-out, transform 0.35s cubic-bezier(.2, .8, .2, 1);
    will-change: opacity, transform;
    margin: 0;
}

.balance-digit.digit-bump,
.energy-digit.digit-bump,
.balance-digit.digit-change,
.energy-digit.digit-change {
    animation: digitBump 0.24s ease-out;
}

.balance-digit.digit-enter,
.energy-digit.digit-enter {
    animation: digitBump 0.24s ease-out;
}

.balance-digit.digit-leave,
.energy-digit.digit-leave {
    animation: digitLeave 0.2s ease-out forwards;
}

@keyframes digitBump {
    0% { transform: translateY(0) scale(1); }
    45% { transform: translateY(-3px) scale(1.08); }
    100% { transform: translateY(0) scale(1); }
}

@keyframes digitEnter {
    0% { opacity: 0; transform: translateY(4px) scale(.86); }
    65% { opacity: 1; transform: translateY(-2px) scale(1.08); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes digitLeave {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(3px) scale(.86); }
}


.balance-digit[data-digit="0"] { background-image: url('/digits/balance_0.png'); }
.balance-digit[data-digit="1"] { background-image: url('/digits/balance_1.png'); }
.balance-digit[data-digit="2"] { background-image: url('/digits/balance_2.png'); }
.balance-digit[data-digit="3"] { background-image: url('/digits/balance_3.png'); }
.balance-digit[data-digit="4"] { background-image: url('/digits/balance_4.png'); }
.balance-digit[data-digit="5"] { background-image: url('/digits/balance_5.png'); }
.balance-digit[data-digit="6"] { background-image: url('/digits/balance_6.png'); }
.balance-digit[data-digit="7"] { background-image: url('/digits/balance_7.png'); }
.balance-digit[data-digit="8"] { background-image: url('/digits/balance_8.png'); }
.balance-digit[data-digit="9"] { background-image: url('/digits/balance_9.png'); }
.balance-digit[data-digit="."] { 
    width: 16px;
    height: 40px;
    background-image: url('/digits/balance_dot.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    vertical-align: bottom;
}

.balance-pill .muted {
    font-weight: 600;
    color: var(--muted);
    font-size: 14px
}

.center {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    pointer-events: auto;
}

.center::before {
    content: "";
    position: absolute;
    left: 50%;
    top: clamp(4px, 1dvh, 14px);
    width: min(100vw, var(--app-max-width));
    height: min(100vw, var(--app-max-width));
    transform: translateX(-50%);
    background: url('/images/background.png') center / 100% 100% no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    z-index: 0;
}

.coin-wrap {
    position: relative;
    z-index: 1;
    margin-top: clamp(10px, 2dvh, 20px);
}

.coin {
    width: clamp(238px, 58vw, 390px);
    height: clamp(238px, 58vw, 390px);
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    touch-action: manipulation;
    transition: transform .28s cubic-bezier(.18, .88, .22, 1);
    padding: 0;
    cursor: pointer;
    -webkit-touch-callout: none;
    position: relative;
    transform-origin: center center;
    will-change: transform;
}

.coin::before {
    content: "";
    position: absolute;
    inset: 8%;
    border-radius: 50%;
    background:
        radial-gradient(circle, rgba(255, 255, 255, 0.28) 0 34%, rgba(255, 255, 255, 0) 35%),
        radial-gradient(circle, rgba(255, 216, 90, 0.35) 0 48%, rgba(255, 216, 90, 0) 64%);
    opacity: 0;
    transform: scale(0.55);
    transform-origin: center;
    pointer-events: none;
    z-index: 0;
}

.coin:hover {
    transform: none;
}

.coin-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
    filter: none;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    pointer-events: none;
    position: relative;
    z-index: 1;
}

.coin:active {
    transform: scale(1.01);
}

.coin.tapped {
    animation: coinTap 0.42s cubic-bezier(.18, .92, .22, 1.08) both;
}

.coin.tapped::before {
    animation: coinBubble 0.48s cubic-bezier(.15, .78, .22, 1) both;
}

@keyframes coinTap {
    0% { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
    18% { transform: translate3d(0, 7px, 0) scale(1.075, 0.91) rotate(-0.8deg); }
    42% { transform: translate3d(0, -11px, 0) scale(0.97, 1.055) rotate(1.2deg); }
    62% { transform: translate3d(0, -4px, 0) scale(1.018, 0.985) rotate(-0.5deg); }
    82% { transform: translate3d(0, 2px, 0) scale(1.012, 0.978) rotate(0deg); }
    100% { transform: translate3d(0, 0, 0) scale(1) rotate(0deg); }
}

@keyframes coinBubble {
    0% { opacity: 0; transform: scale(0.55); filter: blur(0); }
    16% { opacity: 0.72; transform: scale(0.82); filter: blur(0); }
    58% { opacity: 0.28; transform: scale(1.22); filter: blur(1px); }
    100% { opacity: 0; transform: scale(1.46); filter: blur(2px); }
}

.coin:active .coin-image {
    transform: translateZ(0) scale(1);
    -webkit-transform: translateZ(0) scale(1);
    filter: none;
}

.float,
.tap-float {
    position: absolute;
    left: 0;
    top: 0;
    pointer-events: none;
    z-index: 1000;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .8));
    will-change: transform, opacity;
}

.tap-float {
    position: fixed;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 1px;
    z-index: 2147483000;
    min-width: max-content;
    transform: translate(-50%, -50%);
    animation: tapFloatUp 1.08s cubic-bezier(.12, .78, .22, 1) forwards;
}

.tap-float-glyph {
    width: clamp(24px, 6.5vw, 36px);
    height: clamp(24px, 6.5vw, 36px);
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.tap-float-plus {
    width: clamp(22px, 6vw, 34px);
    height: clamp(22px, 6vw, 34px);
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    margin-right: 2px;
}

.tap-float-text {
    color: #111;
    font: 900 clamp(24px, 6.5vw, 36px) / 1 monospace;
    letter-spacing: 1px;
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.35);
}

@keyframes tapFloatUp {
    0% {
        opacity: 0;
        transform: translate(-50%, -40%) scale(.76);
    }
    18% {
        opacity: 1;
        transform: translate(calc(-50% + var(--float-x, 0px) * .16), -72%) scale(1.08);
    }
    58% {
        opacity: .86;
        transform: translate(calc(-50% + var(--float-x, 0px) * .64), -108px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translate(calc(-50% + var(--float-x, 0px)), -154px) scale(.88);
    }
}

.energy-wrapper {
    margin: clamp(-76px, -9dvh, -44px) auto clamp(6px, 1.6dvh, 14px);
    width: 100%;
    max-width: min(100vw, var(--app-max-width));
    position: relative;
    pointer-events: auto;
}

.energy {
    width: 100%;
    background-image: url('/images/energy_frame.png');
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    border: none;
    border-radius: 0;
    padding: 4px 8px 5px;
    image-rendering: pixelated;
    height: calc((var(--content-width) / 4) * 0.62);
    max-height: calc((var(--app-max-width) / 4) * 0.62);
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 0;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.energy-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(2px, 0.9vw, 6px);
    width: 100%;
    position: relative;
    z-index: 2;
    height: 100%;
    justify-content: center;
}

.energy-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    position: relative;
    z-index: 5;
    flex-shrink: 0;
    margin-top: 0;
    min-height: clamp(36px, 8vw, 48px);
    min-width: clamp(118px, 38vw, 230px);
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    overflow: visible;
}

#energyCount,
#energyMax {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.energy-bar-container {
    width: 84%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 20;
    margin-top: 0;
    height: clamp(18px, 4.8vw, 25px);
    min-height: 18px;
    flex-shrink: 0;
    overflow: visible;
}

.energy-bar {
    width: 100%;
    height: 100%;
    min-height: 18px;
    display: block;
    object-fit: fill;
    object-position: center;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    position: relative;
    z-index: 21;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .72));
    transition: opacity .12s ease-out, transform .12s ease-out;
}

.energy-bar[src] {
    opacity: 1;
}

#energyCount {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

#energyMax {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.energy-slash {
    display: inline-block;
    width: 16px;
    height: 28px;
    background-image: url('/digits/energy_slash.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    flex-shrink: 0;
    vertical-align: middle;
}

.energy-digit {
    display: inline-block;
    width: 20px;
    height: 28px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    image-rendering: pixelated;
    flex-shrink: 0;
    vertical-align: middle;
    transition: opacity 0.35s ease-out, transform 0.35s cubic-bezier(.2, .8, .2, 1);
    will-change: opacity, transform;
}

.energy-digit[data-digit="0"] { background-image: url('/digits/energy_digit_0.png'); }
.energy-digit[data-digit="1"] { background-image: url('/digits/energy_digit_1.png'); }
.energy-digit[data-digit="2"] { background-image: url('/digits/energy_digit_2.png'); }
.energy-digit[data-digit="3"] { background-image: url('/digits/energy_digit_3.png'); }
.energy-digit[data-digit="4"] { background-image: url('/digits/energy_digit_4.png'); }
.energy-digit[data-digit="5"] { background-image: url('/digits/energy_digit_5.png'); }
.energy-digit[data-digit="6"] { background-image: url('/digits/energy_digit_6.png'); }
.energy-digit[data-digit="7"] { background-image: url('/digits/energy_digit_7.png'); }
.energy-digit[data-digit="8"] { background-image: url('/digits/energy_digit_8.png'); }
.energy-digit[data-digit="9"] { background-image: url('/digits/energy_digit_9.png'); }
.energy-digit[data-digit="."] { 
    width: 12px;
    height: 28px;
    background-image: url('/digits/energy_dot.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    vertical-align: bottom;
}

.bottom {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    padding-bottom: var(--app-safe-bottom);
    pointer-events: auto;
    transition: opacity 0.25s ease-out, transform 0.25s ease-out;
}

body.modal-open .bottom {
    opacity: 0;
    pointer-events: none;
    transform: translateY(100%);
}

.bottom .wrap {
    display: flex;
    width: 100%;
    max-width: var(--app-max-width);
    height: var(--nav-height);
    gap: 0;
    padding: 0 4px;
    margin: 0 auto;
    box-sizing: border-box;
    align-items: stretch;
    justify-content: center;
}

.bottom::before {
    display: none;
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 8px;
    min-height: 8px;
    border-bottom: 1px solid var(--line);
    background: rgba(8, 12, 18, .9);
    backdrop-filter: blur(6px);
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4)) drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    background: var(--card);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -moz-tap-highlight-color: transparent;
    -ms-tap-highlight-color: transparent;
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    -ms-touch-action: manipulation;
    
    -khtml-user-select: none;
    z-index: 10;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3), 0 2px 4px rgba(0, 0, 0, 0.2);
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}


.btn:not(.bottom .wrap .btn):not(.bottom .wrap .nav-btn) > * {
    pointer-events: none !important;
}


.bottom .wrap .nav-btn {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    max-height: none;
    aspect-ratio: 266 / 208;
    padding: 0;
    margin: 0;

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

    background: transparent;
    border: 0;
    outline: none;
    box-shadow: none;
    border-radius: 0;
    z-index: auto;
    will-change: auto;
    backface-visibility: visible;
    transform: none;

    cursor: pointer;
    pointer-events: auto !important;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;

    position: relative;
    overflow: visible;
    transform-origin: center bottom;
    transition: transform .12s ease-out;
}


.bottom .wrap .nav-btn .btn-icon {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
    image-rendering: pixelated;
    transform: none;
}

.bottom .wrap .nav-btn .nav-label {
    display: none;
}


.bottom .wrap .nav-btn:hover {
    background: transparent;
    border: 0;
    box-shadow: none;
}

.bottom .wrap .nav-btn:active {
    transform: scale(0.97);
    background: transparent;
    border: 0;
    box-shadow: none;
    opacity: 1;
}


.btn:hover:not(:disabled):not(.bottom .wrap .nav-btn) {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.btn:active:not(:disabled):not(.bottom .wrap .nav-btn) {
    transform: scale(.96) translateY(1px) translateZ(0);
    -webkit-transform: scale(.96) translateY(1px) translateZ(0);
    opacity: .9;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn.ok {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.2), rgba(52, 211, 153, 0.1));
    border-color: rgba(52, 211, 153, 0.4);
    color: var(--ok);
}

.btn.ok:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.3), rgba(52, 211, 153, 0.2));
    border-color: rgba(52, 211, 153, 0.6);
}

.btn.warn {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(251, 191, 36, 0.1));
    border-color: rgba(251, 191, 36, 0.4);
    color: var(--warn);
}

.btn.warn:hover:not(:disabled) {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.3), rgba(251, 191, 36, 0.2));
    border-color: rgba(251, 191, 36, 0.6);
}

input.btn,
select.btn {
    text-align: left;
    cursor: text;
    width: 100%;
    min-height: 44px;
    font-family: inherit;
}

input.btn:focus,
select.btn:focus {
    outline: none;
    border-color: var(--accent);
    background: rgba(125, 211, 252, 0.05);
}

select.btn {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%239fb0c3' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.btn-icon {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    image-rendering: pixelated;
    margin: 0;
    padding: 0;
    pointer-events: none !important;
    user-select: none;
    position: relative;
    z-index: 1;
}


.btn.bounce {
    animation: bounceIn .22s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(.85) translateY(3px);
    }
    60% {
        transform: scale(1.12) translateY(-2px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}
.muted {
    color: var(--muted);
    font-size: 13px
}
.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(32, 103, 75, .24);
    backdrop-filter: none;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease-out;
}

.sheet {
    width: 100%;
    max-width: var(--app-max-width);
    background: #0e1621;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    padding: 16px;
    position: relative;
    z-index: 41;
    pointer-events: auto;
}


#upgradesModal .sheet,
#tasksModal .sheet,
#withdrawModal .sheet,
#friendsModal .sheet {
    width: 100vw;
    max-width: none;
    height: 100svh;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    background: transparent;
    border: 0;
    border-radius: 0;
    padding: 0;
    overflow: hidden;
}

#tasksModal .sheet {
    background: transparent;
}

/* ===== Tasks background (background_tasks.png) ===== */
.tasks-skin {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: var(--app-height, 100dvh);
    background: url("/images/background_tasks.png") center / 100% 100% no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}

.task-close {
    position: absolute;
    top: 3.2%;
    right: 4.4%;
    width: clamp(28px, 7.2%, 44px);
    aspect-ratio: 56 / 64;
    padding: 4px;
    border: 0;
    background: transparent;
    cursor: pointer;
    z-index: 8;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.task-close img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}

/* ===== Upgrades background (background_upgrades.png) ===== */
.upgrades-skin {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: var(--app-height, 100dvh);
    background: url("/images/background_upgrades.png") center / 100% 100% no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}


.upg-close {
    position: absolute;
    top: 3.2%;
    right: 4.4%;
    width: clamp(28px, 7.2%, 44px);
    aspect-ratio: 56 / 63;
    padding: 4px;
    border: 0;
    background: transparent;
    cursor: pointer;
    z-index: 8;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.upg-close img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}


.upg-slot {
    position: absolute;
    left: 5.6%;
    width: 88.8%;
    aspect-ratio: 868 / 245;
    min-height: 0;
    border: 0;
    padding: 0;
    background: url("/images/upgrade_button.png") center / 100% 100% no-repeat;
    cursor: pointer;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto !important;
    user-select: none;
    -webkit-user-select: none;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}


.upg-1 { top: 14.8%; }
.upg-2 { top: 33.7%; }
.upg-3 { top: 52.6%; }
.upg-4 { top: 71.5%; }


.upg-text {
    position: absolute;
    left: 7.2%;
    top: 15%;
    right: 7.2%;
    bottom: 14%;
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.34dvh, 5px);
    pointer-events: none;
    max-width: 100%;
    overflow: hidden;
    justify-content: center;
    padding: clamp(4px, 0.9vw, 8px) clamp(7px, 1.6vw, 13px);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    min-width: 0;
    max-height: 100%;
}


.upg-line2 {
    margin-left: 0;
    text-align: left;
}

.upg-line3 {
    margin-left: 0;
    text-align: left;
}

/* ===== Withdraw background (background_withdraw.png) ===== */
.withdraw-skin {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: var(--app-height, 100dvh);
    background: url("/images/background_withdraw.png") center / 100% 100% no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}


.wth-close {
    position: absolute;
    top: 3.2%;
    right: 4.4%;
    width: clamp(28px, 7.2%, 44px);
    aspect-ratio: 56 / 63;
    padding: 4px;
    border: 0;
    background: transparent;
    cursor: pointer;
    z-index: 8;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.wth-close img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}


.wth-slot {
    position: absolute;
    left: 6.6%;
    width: 86.8%;
    aspect-ratio: 868 / 196;
    min-height: 0;
    border: 0;
    padding: 0;
    background: url("/images/withdraw_button.png") center / 100% 100% no-repeat;
    cursor: pointer;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}

.wth-1 { top: 13.7%; }
.wth-2 { top: 27.4%; }
.wth-3 { top: 41.1%; }
.wth-4 { top: 54.8%; }
.wth-5 { top: 68.5%; }
.wth-6 { top: 82.2%; }


.wth-text {
    position: absolute;
    left: 6.5%;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

.wth-label {
    position: absolute;
    left: 8.4%;
    top: 18%;
    right: 8.4%;
    pointer-events: none;
    max-width: 100%;
    overflow: hidden;
    min-height: clamp(25px, 5.6vw, 38px);
    padding: clamp(3px, 0.7vw, 6px) clamp(7px, 1.5vw, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    min-width: 0;
    max-height: 42%;
}

.wth-value {
    position: absolute;
    left: 8.4%;
    top: 57%;
    right: 8.4%;
    pointer-events: none;
    cursor: default;
    min-height: clamp(25px, 5.6vw, 38px);
    outline: none;
    padding: clamp(3px, 0.7vw, 6px) clamp(7px, 1.5vw, 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    min-width: 0;
    max-height: 42%;
}

.wth-slot.wallet-connected .wth-label {
    background: transparent;
    border-color: transparent;
}

.ref-text .bmp-line,
.ref-label .bmp-line {
    justify-content: center;
    align-self: center;
}

.wth-label .bmp-line,
.wth-value .bmp-line {
    justify-content: center;
    align-self: center;
}

.wth-1 .wth-label {
    inset: 0 8.4%;
    min-height: 100%;
    justify-content: center;
}

.wth-6 .wth-label {
    top: 20%;
}

.wth-6 .wth-value {
    top: 55%;
}

.task-text .bmp-line {
    justify-content: flex-start;
    align-self: flex-start;
}

.upg-text .bmp-line {
    justify-content: flex-start;
    align-self: flex-start;
}

.ton-connect-root {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* ===== Referral background (background_referrals.png) ===== */
.referral-skin {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: var(--app-height, 100dvh);
    background: url("/images/background_referrals.png") center / 100% 100% no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}


.ref-close {
    position: absolute;
    top: 3.2%;
    right: 4.4%;
    width: clamp(28px, 7.2%, 44px);
    aspect-ratio: 56 / 63;
    padding: 4px;
    border: 0;
    background: transparent;
    cursor: pointer;
    z-index: 8;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.ref-close img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
}


.ref-slot {
    position: absolute;
    left: 5.8%;
    width: 88.4%;
    aspect-ratio: 868 / 174;
    min-height: 0;
    border: 0;
    padding: 0;
    background: url("/images/referral_button.png") center / 100% 100% no-repeat;
    z-index: 3;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    overflow: hidden;
}

.ref-1 {
    top: 14.7%;
}

.ref-2 {
    top: 31.6%;
    cursor: pointer;
}

.ref-3 {
    top: 48.5%;
    cursor: pointer;
}

.ref-4 {
    top: 65.4%;
}


.ref-text {
    position: absolute;
    left: 7%;
    top: 12%;
    right: 7%;
    bottom: 11%;
    display: flex;
    flex-direction: column;
    gap: clamp(2px, 0.24dvh, 4px);
    pointer-events: none;
    max-width: 100%;
    overflow: hidden;
    justify-content: center;
    align-items: center;
    z-index: 2;
    padding: clamp(4px, 0.9vw, 8px) clamp(7px, 1.6vw, 13px);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    min-width: 0;
    max-height: 100%;
}

.ref-label {
    position: absolute;
    left: 9%;
    top: 50%;
    right: 9%;
    transform: translateY(-50%);
    pointer-events: none;
    max-width: 100%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    min-height: clamp(34px, 7vw, 52px);
    padding: clamp(4px, 0.9vw, 8px) clamp(8px, 1.8vw, 14px);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    min-width: 0;
    max-height: 100%;
}

.ref-text .bmp-glyph,
.ref-label .bmp-glyph {
    width: var(--gW, 13px) !important;
    height: var(--gH, 13px) !important;
    max-width: var(--gW, 13px) !important;
}

.ref-value {
    position: absolute;
    right: 6.5%;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 2;
}

.sheet-full {
    height: 100svh;
    height: var(--app-height, 100dvh);
    border-radius: 0;
    transform: translateY(100%);
    transition: transform .25s ease-out;
    display: block;
    overflow: hidden;
}

.overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.overlay.open .sheet {
    pointer-events: auto;
}

.overlay.open .sheet * {
    pointer-events: none;
}

.overlay.open .upg-slot {
    pointer-events: auto !important;
}

.overlay.open .wth-slot,
.overlay.open .ref-slot,
.overlay.open .task-btn,
.overlay.open .upg-close,
.overlay.open .wth-close,
.overlay.open .ref-close,
.overlay.open .task-close {
    pointer-events: auto !important;
}

.overlay.open .sheet-full {
    transform: translateY(0);
}

.tasks-list {
    position: absolute;
    left: 8.5%;
    right: 8.5%;
    top: 11.2%;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 1.8dvh, 24px);
    z-index: 3;
}

.task-btn {
    width: 100%;
    aspect-ratio: 868 / 174;
    min-height: 0;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    display: block;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.upg-slot.text-needs-room {
    min-height: 0;
}

.wth-slot.text-needs-room {
    min-height: 0;
}

.ref-slot.text-needs-room {
    min-height: 0;
}

.task-btn.text-needs-room {
    min-height: 0;
}

.task-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: url("/images/tasks_button.png") center / 100% 100% no-repeat;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.task-btn .task-text {
    position: absolute;
    left: 7%;
    top: 17%;
    right: 7%;
    bottom: 16%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: clamp(2px, 0.34dvh, 5px);
    pointer-events: none;
    z-index: 2;
    overflow: hidden;
    padding: clamp(4px, 0.9vw, 8px) clamp(7px, 1.6vw, 13px);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    box-sizing: border-box;
    min-width: 0;
    max-height: 100%;
}


.bmp-line {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 0;
    width: max-content;
    max-width: none;
    min-height: var(--gH, 16px);
    overflow: visible;
    row-gap: 4px;
    flex: 0 1 auto;
}


.bmp-glyph {
    width: var(--gW, 22px);
    height: var(--gH, 22px);
    flex: 0 0 auto;
    display: block;
    object-fit: contain;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    user-select: none;
    pointer-events: none;
}

.bmp-glyph-uniform {
    width: var(--gW, 22px) !important;
    min-width: var(--gW, 22px) !important;
    max-width: var(--gW, 22px) !important;
    height: var(--gH, 22px) !important;
    flex: 0 0 var(--gW, 22px);
    object-fit: fill;
}

.bmp-glyph-symbol {
    object-fit: contain;
}

.bmp-glyph-fallback {
    width: var(--gW, 22px);
    min-width: var(--gW, 22px);
    max-width: var(--gW, 22px);
    height: var(--gH, 22px);
    flex: 0 0 var(--gW, 22px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-family: "Courier New", "Lucida Console", monospace;
    font-size: calc(var(--gH, 22px) * 0.92);
    font-weight: 900;
    line-height: 1;
    letter-spacing: 0;
    text-transform: uppercase;
    overflow: hidden;
    -webkit-font-smoothing: none;
    text-rendering: geometricPrecision;
}

.bmp-glyph-fallback[data-fallback-char="!"],
.bmp-glyph-fallback[data-fallback-char="'"] {
    width: calc(var(--gW, 22px) * 0.55);
    min-width: calc(var(--gW, 22px) * 0.55);
    max-width: calc(var(--gW, 22px) * 0.55);
    flex-basis: calc(var(--gW, 22px) * 0.55);
}

.bmp-glyph-fallback[data-fallback-char="/"] {
    width: calc(var(--gW, 22px) * 0.72);
    min-width: calc(var(--gW, 22px) * 0.72);
    max-width: calc(var(--gW, 22px) * 0.72);
    flex-basis: calc(var(--gW, 22px) * 0.72);
}

.bmp-glyph-fallback[data-fallback-char="_"] {
    align-items: flex-end;
    padding-bottom: calc(var(--gH, 22px) * 0.08);
}


.bmp-space {
    width: var(--spaceW, 10px);
    height: 1px;
    display: inline-block;
}

.upgrades-skin,
.tasks-skin,
.withdraw-skin,
.referral-skin {
    width: min(100vw, var(--app-max-width));
    max-width: var(--app-max-width);
    margin: 0 auto;
}

.upg-close,
.wth-close,
.ref-close,
.task-close {
    top: 3.2%;
    right: 4.4%;
    width: clamp(42px, 10vw, 58px);
    height: auto;
    aspect-ratio: 56 / 63;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 12;
    overflow: visible;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    border: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: absolute;
}

.task-close {
    aspect-ratio: 56 / 64;
}

.upg-close img,
.wth-close img,
.ref-close img,
.task-close img {
    width: 74%;
    height: 74%;
    filter: none;
}

.upg-close:active,
.wth-close:active,
.ref-close:active,
.task-close:active,
.upg-slot:active,
.wth-slot:active,
.ref-slot:active,
.task-btn:active {
    transform: translateY(1px) scale(0.985);
}

.upg-slot,
.wth-slot,
.ref-slot,
.task-btn {
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.26));
}

.tasks-list {
    top: 11.2%;
    gap: clamp(12px, 1.8dvh, 24px);
}

.task-btn {
    min-height: clamp(72px, 19vw, 116px);
}

@media (pointer: fine) {
    button,
    .coin,
    .nav-btn,
    .upg-slot,
    .wth-slot,
    .ref-slot,
    .task-btn,
    .upg-close,
    .wth-close,
    .ref-close,
    .task-close {
        cursor: pointer;
    }
}

strong {
    font-weight: 700;
    color: var(--text);
    font-size: 16px;
}

#friendsModal button.btn,
#tasksModal button.btn {
    min-height: 44px;
    font-weight: 600;
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    position: relative;
    z-index: 10;
}

button:disabled,
input:disabled,
select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.api-test-panel {
    position: fixed;
    top: calc(var(--app-safe-top) + 8px);
    right: 8px;
    width: min(360px, calc(100vw - 16px));
    z-index: 1500;
    border: 1px solid rgba(122, 209, 255, 0.35);
    border-radius: 14px;
    background: rgba(8, 14, 24, 0.92);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.36);
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.api-test-panel.collapsed .api-test-body {
    display: none;
}

.api-test-toggle {
    width: 100%;
    border: 0;
    border-bottom: 1px solid rgba(122, 209, 255, 0.2);
    background: linear-gradient(180deg, rgba(34, 52, 84, 0.96), rgba(15, 25, 43, 0.96));
    color: #d9edff;
    font-size: 12px;
    letter-spacing: 0.12em;
    font-weight: 800;
    padding: 10px 12px;
    text-align: left;
}

.api-test-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: min(52vh, 390px);
}

.api-test-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.api-test-btn {
    border: 1px solid rgba(125, 211, 252, 0.45);
    border-radius: 10px;
    background: rgba(26, 42, 68, 0.88);
    color: #eef7ff;
    font-size: 12px;
    font-weight: 700;
    padding: 9px 8px;
    text-align: center;
}

.api-test-btn:active {
    transform: translateY(1px) scale(0.99);
}

.api-test-output {
    margin: 0;
    border: 1px solid rgba(125, 211, 252, 0.24);
    border-radius: 10px;
    background: rgba(7, 14, 24, 0.96);
    color: #d9f0ff;
    font-size: 11px;
    line-height: 1.35;
    padding: 8px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    min-height: 84px;
    max-height: 220px;
}

@media (max-width: 520px) {
    .api-test-panel {
        top: calc(var(--app-safe-top) + 4px);
        right: 4px;
        width: calc(100vw - 8px);
    }
}


