@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@800;900&display=swap');

        :root {
            --img-fon: url('../../assets/fon.png');
            --img-ice: url('../../assets/ice.png');
            --img-profile: url('../../assets/profile.png');
        }

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

        body {
            background-color: #87CEEB;
            overflow: hidden;
            width: 100vw;
            height: var(--tg-viewport-stable-height, 100vh);
            user-select: none;
            -webkit-user-select: none;
            -webkit-touch-callout: none;
            touch-action: none;
            font-family: 'Nunito', sans-serif;
        }

        img { -webkit-user-drag: none; user-select: none; }

        #game-container {
            position: relative;
            width: 100%;
            height: 100%;
            background-image: var(--img-fon);
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }

        /* ---------------- ЭКРАН ЗАГРУЗКИ ---------------- */
        #loading-screen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100vw;
            height: var(--tg-viewport-stable-height, 100vh);
            background-color: #0f172a;
            display: flex;
            flex-direction: column;
            justify-content: flex-end;
            align-items: center;
            z-index: 9999;
            transition: opacity 0.5s ease;
            overflow: hidden;
        }

        #loading-screen.hidden {
            opacity: 0;
            pointer-events: none;
        }

        #loading-img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            z-index: -1;
        }

        .loading-ui {
            width: 100%;
            padding: 20px 20px 50px 20px;
            display: flex;
            flex-direction: column;
            align-items: center;
            background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
            z-index: 1;
        }

        #loading-bar-container {
            width: 85vw;
            max-width: 400px;
            height: 32px;
            background-color: rgba(0, 0, 0, 0.6);
            border: 3px solid #93c5fd;
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 4px 15px rgba(0,0,0,0.6);
            position: relative;
        }

        #loading-bar {
            width: 0%;
            height: 100%;
            background: linear-gradient(90deg, #3b82f6, #93c5fd);
            transition: width 0.1s linear;
            box-shadow: inset 0 0 10px rgba(255,255,255,0.5);
        }

        #loading-text {
            margin-top: 15px;
            color: #fff;
            font-weight: 900;
            font-size: 20px;
            letter-spacing: 2px;
            text-shadow: 0 2px 5px rgba(0,0,0,0.9);
            text-transform: uppercase;
        }

        /* ---------------- ВЕРХНЯЯ ПАНЕЛЬ ---------------- */
        #top-ui {
            position: absolute;
            top: calc(15px + max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px)));
            left: 10px;
            right: 10px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            z-index: 100;
            pointer-events: none;
        }

        .profile-area { height: 64px; display: flex; align-items: center; gap: 7px; flex: 1 1 auto; min-width: 0; max-width: min(62vw, 260px); padding: 5px 7px; border: 1px solid rgba(155,218,250,.9); border-radius: 15px; background: linear-gradient(145deg, rgba(45,101,148,.98), rgba(20,57,91,.98)); box-shadow: 0 3px 0 rgba(7,29,51,.75), 0 5px 12px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.18); }
        .profile-summary { flex: 1 1 auto; width: auto; min-width: 0; display: flex; flex-direction: column; gap: 4px; color: #eff9ff; text-shadow: 0 1px 3px #102b49; pointer-events: none; }
        .player-display-name { overflow: hidden; color: #fff; font-size: clamp(11px, 3.5vw, 15px); font-weight: 1000; line-height: 1.05; text-overflow: ellipsis; white-space: nowrap; }
        .profile-level-row { display: flex; align-items: center; justify-content: space-between; gap: 4px; overflow: hidden; color: #d9f2ff; font-size: 9px; font-weight: 900; line-height: 1; white-space: nowrap; }
        #player-level-progress { opacity: .9; }
        .profile-level-track { height: 6px; overflow: hidden; border: 1px solid rgba(255,255,255,.86); border-radius: 99px; background: rgba(3,21,41,.58); box-shadow: 0 1px 3px rgba(0,0,0,.3); }
        .profile-level-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #4bd6ff, #b8f4ff); box-shadow: 0 0 8px #79ddff; transition: width .25s ease; }

        .profile-box {
            position: relative;
            width: 45px;
            height: 45px;
            background-color: #d7f1ff;
            border: 2px solid #b9e8ff;
            border-radius: 50%;
            box-shadow: 0 2px 0 #123b60, 0 4px 8px rgba(0,0,0,0.28);
            overflow: visible;
            flex-shrink: 0;
            background-image: var(--img-profile);
            background-size: cover;
            background-position: center;
            pointer-events: auto;
            cursor: pointer;
        }
        .profile-vip { position: absolute; top: 42px; left: 0; max-width: 112px; padding: 3px 6px; border: 1px solid #b9e8ff; border-radius: 9px; background: linear-gradient(135deg,#dff6ff,#78caff); color: #123b60; font-size: 9px; line-height: 1.15; font-weight: 1000; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,.25); }
        .profile-vip:empty { display: none; }

        .resources {
            display: flex;
            flex: 0 0 clamp(96px, 32vw, 124px);
            height: 64px;
            flex-direction: column;
            gap: 4px;
            align-items: stretch;
        }

        .resource-box {
            display: flex;
            flex: 1 1 0;
            align-items: center;
            min-width: 0;
            min-height: 30px;
            padding: 3px 8px;
            border: 1px solid rgba(155,218,250,.9);
            border-radius: 11px;
            color: #f2fbff;
            background: linear-gradient(145deg, rgba(45,101,148,.98), rgba(20,57,91,.98));
            box-shadow: 0 2px 0 rgba(7,29,51,.75), 0 4px 8px rgba(0,0,0,.23), inset 0 1px 0 rgba(255,255,255,.15);
            position: relative;
            transition: transform 0.1s, background 0.2s;
        }

        .pop {
            transform: scale(1.1);
            background: linear-gradient(145deg, #72caff, #2f83bb);
        }

        .resource-box.deny {
            animation: denyAnim 0.4s;
        }

        @keyframes denyAnim {
            0%, 100% { background: rgba(255,255,255,0.9); transform: translateX(0); }
            20% { background: #fecaca; transform: translateX(-4px); }
            40% { background: #fecaca; transform: translateX(4px); }
            60% { background: #fecaca; transform: translateX(-3px); }
            80% { background: #fecaca; transform: translateX(3px); }
        }

        .resource-icon {
            width: 22px;
            height: 22px;
            background-size: contain;
            background-repeat: no-repeat;
            background-position: center;
            margin-right: 7px;
            filter: drop-shadow(0 2px 2px rgba(0,0,0,0.3));
            flex-shrink: 0;
        }

        .icon-ice { background-image: var(--img-ice); }

        .icon-dollar {
            background: #4caf50;
            border: 2px solid #2e7d32;
            border-radius: 4px;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: inset 0 0 5px rgba(0,0,0,0.3);
        }

        .icon-dollar::after {
            content: '$';
            color: #fff;
            font-size: 14px;
            font-weight: 900;
            text-shadow: 1px 1px 0 #1b5e20;
        }

        .resource-value {
            min-width: 0;
            overflow: hidden;
            font-weight: 900;
            font-size: clamp(10px, 3vw, 13px);
            color: #f2fbff;
            text-shadow: 0 1px 2px #102b49;
            text-overflow: ellipsis;
            white-space: nowrap;
        }

        /* ---------------- НИЖНЕЕ МЕНЮ ---------------- */
        #bottom-nav {
            position: absolute;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 75px;
            background: linear-gradient(to top, #1e3a8a, #3b82f6);
            border-top: 3px solid #93c5fd;
            display: flex;
            justify-content: space-around;
            align-items: center;
            z-index: 100;
            padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px), var(--tg-content-safe-area-inset-bottom, 0px));
            box-shadow: 0 -5px 15px rgba(0,0,0,0.3);
        }

        .nav-btn {
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            color: #bfdbfe;
            font-size: 9px;
            font-weight: 800;
            text-transform: uppercase;
            flex: 1;
            height: 100%;
            opacity: 0.7;
            transition: opacity 0.2s, transform 0.2s;
            cursor: pointer;
        }

        .nav-icon {
            width: 28px;
            height: 28px;
            display: grid;
            place-items: center;
            margin-bottom: 2px;
            font-size: 23px;
            line-height: 1;
            filter: drop-shadow(0 2px 2px rgba(0,0,0,0.4));
            transition: transform 0.2s;
        }

        .nav-btn.active {
            opacity: 1;
            color: #ffffff;
            background: linear-gradient(to top, rgba(255,255,255,0.1), transparent);
            border-top: 3px solid #fbbf24;
            position: relative;
        }
        .nav-btn.active::before {
            content: '';
            position: absolute;
            top: -3px;
            width: 30px;
            height: 3px;
            background: #fbbf24;
            box-shadow: 0 0 10px #fbbf24;
        }

        .nav-btn.active .nav-icon {
            transform: scale(1.1) translateY(-2px);
            filter: drop-shadow(0 0 8px #fbbf24);
        }

        .nav-btn:active .nav-icon {
            transform: scale(0.9);
        }

        /* ---------------- ЭКРАНЫ ---------------- */
        .screen {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
        .screen.hidden { display: none; }
