@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
    --bg: #0d1117;
    --bg2: #0f1520;
    --card: #111827;
    --card2: #131d2e;
    --border: #1e2d45;
    --accent: #2563eb;
    --accent-light: #3b82f6;
    --text: #f1f5f9;
    --text2: #475569;
    --text3: #64748b;
}

html, body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior: none;
}

/* ===== LOADER ===== */
#loader {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 999;
    transition: opacity 0.5s ease;
}
#loader.fade-out { opacity: 0; pointer-events: none; }

#lottie-container { width: 200px; height: 200px; }

.loader-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: 0.3px;
}

.loader-dots { display: flex; gap: 6px; }
.loader-dots span {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--accent-light);
    animation: dotPulse 1.4s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotPulse {
    0%,80%,100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.3); }
}

/* ===== APP ===== */
#app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-bottom: 96px;
}
#app.hidden { display: none; }

/* ===== HERO ===== */
.hero {
    position: relative;
    overflow: hidden;
    padding-bottom: 28px;
    background: linear-gradient(180deg, #0a1628 0%, #0d1117 100%);
}

/* Декоративный фон */
.hero-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.hero-glow {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(37,99,235,0.18) 0%, transparent 70%);
    border-radius: 50%;
}

.deco {
    position: absolute;
    color: rgba(59,130,246,0.12);
}
.deco-1 { width: 48px; height: 48px; top: 18px; left: 14px; transform: rotate(-15deg); }
.deco-2 { width: 28px; height: 28px; top: 60px; left: 52px; transform: rotate(10deg); opacity: 0.6; }
.deco-3 { width: 56px; height: 56px; top: 10px; right: 16px; transform: rotate(20deg); }
.deco-4 { width: 32px; height: 32px; top: 70px; right: 50px; transform: rotate(-10deg); opacity: 0.5; }
.deco-5 { width: 22px; height: 22px; bottom: 40px; left: 30px; transform: rotate(5deg); opacity: 0.4; }
.deco-6 { width: 36px; height: 36px; bottom: 30px; right: 24px; transform: rotate(-20deg); opacity: 0.5; }

/* ===== TOP BAR ===== */
.top-bar {
    display: flex;
    justify-content: flex-end;
    padding: 16px 16px 0;
    position: relative;
    z-index: 2;
}

.balance-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.06);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 99px;
    padding: 10px 10px 10px 14px;
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.balance-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text3);
    margin-left: -4px;
}

.ton-icon { width: 22px; height: 22px; object-fit: contain; }

.plus-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.plus-btn:active { opacity: 0.7; }

/* ===== PROFILE SECTION ===== */
.profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 16px 0;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.avatar-wrap {
    position: relative;
    width: 100px; height: 100px;
}

.avatar-ring-outer {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--accent), var(--accent-light), transparent, var(--accent));
    animation: rotateBorder 4s linear infinite;
    z-index: 0;
}
@keyframes rotateBorder { to { transform: rotate(360deg); } }

.avatar {
    position: relative;
    z-index: 1;
    width: 100px; height: 100px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--card);
    border: 3px solid var(--bg);
    display: block;
}

.username {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.3px;
}

/* ===== ACTION ===== */
.action-area {
    padding: 20px 16px 0;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    background: var(--accent);
    border: none;
    border-radius: 99px;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity 0.15s, transform 0.1s;
    box-shadow: 0 4px 24px rgba(37,99,235,0.35);
}
.btn-primary:active { opacity: 0.85; transform: scale(0.98); }

/* ===== INVENTORY ===== */
.inventory-section {
    margin: 24px 16px 0;
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 18px;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.inventory-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.inventory-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text2);
    font-size: 13px;
}
.inventory-empty svg { opacity: 0.25; }

/* ===== PROFILE — сдвиг вниз ===== */
.hero { padding-top: 56px; }
.profile-section { padding-top: 52px; }
.action-area { padding-top: 28px; }
.inventory-section { margin-top: 28px; min-height: 300px; }

/* ===== UPGRADER ===== */
.upg-top-bar { padding-top: 80px; }

.upg-wheel-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 36px;
}

.upg-wheel {
    position: relative;
    width: 360px;
    height: 360px;
}

/* Декоративный фон */
.upg-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

.upg-glow {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 280px; height: 280px;
    background: radial-gradient(circle, rgba(37,99,235,0.14) 0%, transparent 70%);
    border-radius: 50%;
}

.upg-deco {
    position: absolute;
    color: rgba(59,130,246,0.1);
}
.upg-deco-1 { width: 40px; height: 40px; top: 20px; left: 20px; transform: rotate(-15deg); }
.upg-deco-2 { width: 24px; height: 24px; top: 70px; left: 10px; transform: rotate(10deg); opacity: 0.6; }
.upg-deco-3 { width: 36px; height: 36px; top: 16px; right: 20px; transform: rotate(20deg); }
.upg-deco-4 { width: 28px; height: 28px; bottom: 30px; left: 14px; transform: rotate(5deg); opacity: 0.5; }
.upg-deco-5 { width: 32px; height: 32px; bottom: 24px; right: 16px; transform: rotate(-20deg); opacity: 0.5; }

#upgradeCanvas {
    position: absolute;
    inset: 0;
    width: 360px;
    height: 360px;
    z-index: 2; /* поверх фона, поверх inner-текста не нужно — inner pointer-events:none */
}

.upg-wheel-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: none;
    z-index: 1; /* ниже canvas — стрелка не перекрывается */
}

.upg-chance-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 1.2px;
}

.upg-chance-value {
    font-size: 44px;
    font-weight: 900;
    color: var(--text);
    letter-spacing: -2px;
    line-height: 1;
}

.upg-result-text {
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    padding: 0 16px;
    line-height: 1.4;
    max-width: 140px;
}

/* Множители */
.upg-multipliers {
    display: flex;
    gap: 10px;
    padding: 22px 16px 0;
    justify-content: center;
}

.upg-mult {
    flex: 1;
    max-width: 72px;
    padding: 11px 0;
    background: rgba(255,255,255,0.04);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    color: var(--text3);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.upg-mult.active {
    background: rgba(37,99,235,0.15);
    border-color: var(--accent);
    color: var(--accent-light);
    box-shadow: 0 0 16px rgba(37,99,235,0.2);
}

/* ===== PAGES ===== */
.page { display: none; }
.page.active { display: block; }

.page-title {
    font-size: 20px; font-weight: 800;
    padding: 24px 16px 12px;
}

.coming-soon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text2);
    font-size: 13px;
}

/* ===== BOTTOM NAV ===== */
.nav-wrap {
    position: fixed;
    bottom: 12px;
    left: 12px;
    right: 12px;
    z-index: 100;
}

.bottom-nav {
    background: rgba(15,21,32,0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 26px;
    display: flex;
    padding: 10px 6px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.nav-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--text2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    padding: 5px 0;
    font-family: 'Inter', sans-serif;
    transition: color 0.2s;
    border-radius: 16px;
}

.nav-btn.active { color: var(--accent-light); }
.nav-btn.active svg { filter: drop-shadow(0 0 5px rgba(59,130,246,0.6)); }
