/* Внешний вид мини-аппа с кейсами подарков. Ориентир — скрины Epic Gift,
   которые прислал владелец: тёмный фон, фиолетовый акцент, крупные скруглённые
   карточки, баланс в TON в липкой шапке. Логики нет, только вид. */

:root {
    --bg: #101014;
    --bg-2: #16161c;
    --card: #1c1c23;
    --card-2: #24242d;
    --line: #2a2a34;
    --text: #ffffff;
    --muted: #8a8f9c;
    --accent: #7c5cff;
    --accent-2: #9b7bff;
    --gold: #f5b433;
    --green: #2fbf71;
    --ton: #2aabee;
    --danger: #e5484d;
    --r-lg: 20px;
    --r-md: 14px;
    --r-sm: 10px;
    --nav-h: 74px;
}

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

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
    overscroll-behavior: none;
}

body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); }

img { max-width: 100%; }
button { font: inherit; color: inherit; border: none; background: none; cursor: pointer; }

/* ---------- шапка с балансом ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(16, 16, 20, 0.86);
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border-bottom: 1px solid var(--line);
}

.avatar {
    width: 46px; height: 46px; border-radius: 50%;
    background: linear-gradient(135deg, #3b4a8f, #6d4bd8);
    display: grid; place-items: center;
    font-size: 20px; flex-shrink: 0;
}

.balance-label { font-size: 13px; color: var(--muted); line-height: 1.2; }
.balance-value { display: flex; align-items: center; gap: 7px; font-size: 22px; font-weight: 700; }

.ton-coin {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--ton);
    display: inline-grid; place-items: center;
    font-size: 12px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.ton-coin.sm { width: 16px; height: 16px; font-size: 9px; }

.btn-topup {
    margin-left: auto;
    display: flex; align-items: center; gap: 8px;
    background: var(--accent);
    padding: 13px 20px;
    border-radius: var(--r-md);
    font-weight: 600; font-size: 15px;
}
.btn-topup:active { background: var(--accent-2); }

/* ---------- лента последних выигрышей ---------- */

.live {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 0 12px 14px;
}
.live-label {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 11px; color: var(--muted); flex-shrink: 0;
    writing-mode: vertical-rl; transform: rotate(180deg);
    letter-spacing: 0.04em;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.live-row { display: flex; gap: 8px; overflow-x: auto; padding-right: 14px; scrollbar-width: none; }
.live-row::-webkit-scrollbar { display: none; }
.live-item {
    width: 54px; height: 54px; border-radius: var(--r-md);
    display: grid; place-items: center; font-size: 26px; flex-shrink: 0;
}

/* ---------- баннеры игр ---------- */

.screen { padding: 0 14px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

.banner {
    position: relative; overflow: hidden;
    border-radius: var(--r-lg);
    padding: 22px 18px;
    min-height: 116px;
    display: flex; flex-direction: column; justify-content: center;
}
.banner-title { display: flex; align-items: center; gap: 10px; font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.banner-sub { margin-top: 4px; font-size: 13px; opacity: 0.75; }

.pill-hit {
    position: absolute; top: 16px; left: 18px;
    background: #fff; color: #14141a;
    padding: 6px 12px; border-radius: 999px;
    font-size: 13px; font-weight: 700;
}
.banner.has-pill { padding-top: 52px; }

.banner-rocket { background: linear-gradient(120deg, #4aa8f0, #7cc8ff); color: #0d2740; }
.banner-pvp { background: linear-gradient(120deg, #f0a92a, #f5c85a); color: #3a2504; }
.banner-hub { background: linear-gradient(120deg, #7b3fe4, #a45bff); color: #fff; }
.banner-upgrade { background: linear-gradient(120deg, #22b455, #4ade80); color: #06301a; }

/* множители у «Ракетки» — врассыпную вокруг ракеты, как в образце,
   поэтому не колонкой справа, а по углам, чтобы не лезли на рисунок */
.mult-chips { position: absolute; right: 96px; top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.mult-chip {
    background: rgba(255,255,255,0.9); color: #0d2740;
    font-size: 12px; font-weight: 700;
    padding: 4px 9px; border-radius: 8px;
}
.banner-art { position: absolute; right: 14px; bottom: 8px; font-size: 56px; opacity: 0.95; }

.pvp-players { position: absolute; right: 0; top: 0; bottom: 0; display: flex; }
.pvp-player {
    width: 84px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    border-left: 1px solid rgba(0,0,0,0.15);
    background: rgba(0,0,0,0.12);
}
.pvp-player .face { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: rgba(0,0,0,0.25); }
.pvp-player .nick { font-size: 11px; font-weight: 700; max-width: 76px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvp-player .share { font-size: 12px; font-weight: 700; opacity: 0.85; }

.hub-previews { position: absolute; right: 10px; top: 10px; bottom: 10px; display: flex; gap: 8px; }
.hub-preview { width: 78px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 30px; }

/* ---------- сетка кейсов ---------- */

.grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
    margin-top: 12px;
}

.case {
    position: relative;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
    display: flex; flex-direction: column;
}
.case.free24 { border-color: var(--gold); }
.case.free { border-color: var(--accent); }
.case.farm { border-color: var(--green); }

.case-art {
    height: 148px;
    display: grid; place-items: center;
    font-size: 42px;
    position: relative;
    background: radial-gradient(circle at 50% 55%, rgba(255,255,255,0.16), transparent 62%);
}
.case-art .cluster { display: flex; gap: 2px; align-items: center; }
.case-art .cluster span:nth-child(2) { font-size: 54px; }
.case-word {
    position: absolute; top: 14px; left: 0; right: 0;
    text-align: center; font-size: 22px; font-weight: 900; letter-spacing: 0.02em;
    text-shadow: 0 2px 10px rgba(0,0,0,0.6);
}

.case-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px 12px 14px;
    background: var(--card-2);
}
.case-name { font-size: 15px; font-weight: 600; }
.price {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent); color: #fff;
    padding: 8px 13px; border-radius: var(--r-sm);
    font-size: 14px; font-weight: 700;
}
.price.gold { background: var(--gold); color: #2a1d00; }
.price.green { background: var(--green); color: #04301a; }

.badge {
    position: absolute; top: 10px; left: 10px; z-index: 2;
    background: var(--gold); color: #2a1d00;
    font-size: 11px; font-weight: 800;
    padding: 6px 11px; border-radius: 999px;
    letter-spacing: 0.02em;
}
.ribbon {
    position: absolute; top: 0; left: 0; right: 0; z-index: 2;
    background: #8c2b2b; color: #ffe6e6;
    font-size: 11px; font-weight: 800; letter-spacing: 0.08em;
    text-align: center; padding: 6px 0;
}

/* ---------- общие блоки ---------- */

.h1 { font-size: 28px; font-weight: 800; margin: 18px 0 14px; }
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 18px;
}
.muted { color: var(--muted); }
.center { text-align: center; }

.btn {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    width: 100%;
    background: var(--accent);
    padding: 16px; border-radius: var(--r-md);
    font-size: 16px; font-weight: 600;
}
.btn.ghost { background: var(--card-2); }
.btn.blue { background: linear-gradient(100deg, #2f7bf6, #37a2ff); }
.btn:active { filter: brightness(1.12); }

.tabs { display: flex; gap: 10px; margin: 14px 0; }
.tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--card-2); padding: 14px; border-radius: var(--r-md);
    font-weight: 600; font-size: 15px;
}
.tab.on { background: var(--accent); }
.tab .count {
    background: var(--danger); color: #fff;
    font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px; border-radius: 999px;
    display: grid; place-items: center; padding: 0 5px;
}

/* ---------- инвентарь (пусто) ---------- */

.empty-icon {
    width: 84px; height: 84px; border-radius: 50%;
    background: var(--card-2); display: grid; place-items: center;
    margin: 0 auto 22px; font-size: 34px;
}
.sep { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; margin: 22px 0; }
.sep::before, .sep::after { content: ""; height: 1px; background: var(--line); flex: 1; }

/* ---------- рефералка ---------- */

.ref-head { display: flex; gap: 16px; align-items: flex-start; }
.ref-icon { width: 58px; height: 58px; border-radius: var(--r-md); background: var(--accent); display: grid; place-items: center; font-size: 26px; flex-shrink: 0; }
.ticket {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--card-2); padding: 4px 10px; border-radius: 8px;
    font-weight: 700; font-size: 14px;
}
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-between + .row-between { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }

/* ---------- рейтинг ---------- */

.rank {
    display: flex; align-items: center; gap: 12px;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 12px; margin-bottom: 10px;
}
.rank.gold { background: linear-gradient(100deg, #5a4410, #product); background: linear-gradient(100deg, #5a4410, #2b2110); border-color: #7a5c14; }
.rank.silver { background: linear-gradient(100deg, #3a3a42, #24242b); border-color: #4a4a55; }
.rank.bronze { background: linear-gradient(100deg, #4d3116, #2b1d10); border-color: #6b4420; }
.rank-num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--card-2); flex-shrink: 0; }
.rank.gold .rank-num { background: var(--gold); color: #2a1d00; }
.rank.silver .rank-num { background: #b9bcc6; color: #22222a; }
.rank.bronze .rank-num { background: #c2803f; color: #2a1600; }
.rank-face { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: var(--card-2); flex-shrink: 0; }
.rank-nick { flex: 1; font-weight: 600; }
.rank-prize { width: 46px; height: 46px; border-radius: var(--r-sm); background: var(--card-2); display: grid; place-items: center; font-size: 22px; }
.rank-score { background: rgba(124,92,255,0.22); color: #cfc3ff; padding: 10px 12px; border-radius: var(--r-sm); font-weight: 700; font-size: 14px; }

.you-bar {
    position: sticky; bottom: calc(var(--nav-h) + 8px);
    display: flex; align-items: center; gap: 12px;
    background: var(--card-2); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 10px 12px; margin-top: 14px;
}

/* ---------- задания ---------- */

.task { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px; margin-bottom: 10px; }
.task-top { display: flex; align-items: flex-start; gap: 12px; }
.task-ico { width: 46px; height: 46px; border-radius: var(--r-sm); background: var(--card-2); display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.task-name { flex: 1; font-size: 16px; font-weight: 600; line-height: 1.3; }
.task-timer { color: var(--gold); font-size: 12px; font-weight: 600; white-space: nowrap; }
.task-mid { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 10px; }
.reward { display: inline-flex; align-items: center; gap: 8px; background: var(--card-2); padding: 12px 16px; border-radius: var(--r-sm); font-weight: 700; }
.btn-sm { display: inline-flex; align-items: center; gap: 8px; background: var(--accent); padding: 12px 18px; border-radius: var(--r-md); font-weight: 600; font-size: 14px; }
.bar { height: 4px; background: var(--card-2); border-radius: 2px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.task-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- розыгрыши ---------- */

.raffle { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; margin-bottom: 12px; }
.raffle-head { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 14px; }
.raffle-count { background: var(--card-2); padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.prizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.prize { border-radius: var(--r-md); padding: 14px 6px 10px; text-align: center; }
.prize .pic { font-size: 40px; }
.prize .nm { font-size: 13px; font-weight: 600; margin-top: 8px; }
.prize .no { font-size: 12px; color: rgba(255,255,255,0.65); }
.raffle-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.stat { background: var(--card-2); border-radius: var(--r-md); padding: 12px 14px; }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 19px; font-weight: 700; margin-top: 6px; }

/* ---------- ракетка ---------- */

.crash-wrap { padding-top: 8px; }
.crash-circle {
    width: 210px; height: 210px; margin: 10px auto 18px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 64px; font-weight: 800;
    background: radial-gradient(circle, rgba(47,191,113,0.16), transparent 70%);
    border: 5px solid var(--green);
    border-right-color: transparent;
    transition: transform 0.2s;
}
.crash-history { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.crash-history::-webkit-scrollbar { display: none; }
.chip {
    border: 1px solid var(--line); background: var(--card);
    border-radius: 10px; padding: 9px 13px; font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.chip.win { border-color: var(--green); color: #7ee2a8; }
.chip.lose { border-color: #3a4b7a; color: #9fb4e8; }

.bet { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; margin-bottom: 10px; }
.bet .face { width: 42px; height: 42px; border-radius: var(--r-sm); background: var(--card-2); display: grid; place-items: center; font-size: 20px; }
.bet .nick { flex: 1; font-weight: 600; }
.bet .amt { background: rgba(42,171,238,0.16); color: #8fd6ff; padding: 9px 12px; border-radius: var(--r-sm); font-weight: 700; display: flex; align-items: center; gap: 6px; }

/* ---------- открытие кейса ---------- */

.roulette { position: relative; height: 128px; overflow: hidden; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--line); margin: 16px 0; }
.roulette-track { display: flex; gap: 10px; padding: 12px; position: absolute; left: 0; top: 0; }
.roulette-item { width: 104px; height: 104px; border-radius: var(--r-md); display: grid; place-items: center; font-size: 44px; flex-shrink: 0; }
.needle { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; background: var(--accent); transform: translateX(-50%); z-index: 3; }

/* ---------- нижняя навигация ---------- */

.nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: grid; grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(16,16,20,0.94);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    font-size: 11px; color: var(--muted);
    padding: 8px 2px; border-radius: var(--r-md);
    position: relative;
}
.nav-item .ico { font-size: 21px; line-height: 1; }
.nav-item.on { color: #fff; background: var(--accent); }
.nav-item .dot {
    position: absolute; top: 2px; right: 14px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 19px; height: 19px; border-radius: 999px;
    display: grid; place-items: center; padding: 0 4px;
}

.page { display: none; }
.page.on { display: block; animation: in 0.18s ease-out; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.back { display: flex; align-items: center; gap: 8px; padding: 14px; font-weight: 600; }
