:root {
    --bg: var(--tg-theme-bg-color, #0b0b1e);
    --text: var(--tg-theme-text-color, #ffffff);
    --hint: var(--tg-theme-hint-color, #7a7a95);
    --accent: #6c5ce7;
    --accent-light: #a29bfe;
    --purple: #8b5cf6;
    --pink: #ec4899;
    --orange: #f59e0b;
    --green: #10b981;
    --red: #ef4444;
    --card-bg: rgba(255, 255, 255, 0.04);
    --card-border: rgba(255, 255, 255, 0.06);
    --radius: 20px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.app {
    max-width: 100vw;
    min-height: 100vh;
    position: relative;
}

/* ========== TOP HEADER ========== */
.top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(to bottom, var(--bg) 70%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--pink));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.header-user {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.header-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.header-tag {
    font-size: 11px;
    color: var(--hint);
}

.header-right {
    display: flex;
    align-items: center;
}

.balance-box {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 100px;
    transition: all 0.3s ease;
}

.balance-icon {
    font-size: 16px;
}

.balance-value {
    font-size: 16px;
    font-weight: 800;
    background: linear-gradient(135deg, #fdcb6e, #f39c12);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    min-width: 20px;
    text-align: right;
}

.balance-box.pulse {
    animation: balancePulse 0.5s ease;
    border-color: rgba(253, 203, 110, 0.4);
    box-shadow: 0 0 20px rgba(253, 203, 110, 0.15);
}

@keyframes balancePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* ========== REWARD BADGE ========== */
.reward-badge {
    display: inline-block;
    padding: 6px 16px;
    background: linear-gradient(135deg, rgba(253, 203, 110, 0.12), rgba(243, 156, 18, 0.12));
    border: 1px solid rgba(253, 203, 110, 0.2);
    border-radius: 100px;
    font-size: 14px;
    font-weight: 700;
    color: #fdcb6e;
    margin-bottom: 12px;
    letter-spacing: 0.3px;
}

/* ========== SCREENS ========== */
.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    z-index: 1;
    padding: 70px 20px 80px;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

.screen-inner {
    width: 100%;
    max-width: 380px;
    text-align: center;
    animation: fadeSlideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(40px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Transition out */
.screen.leaving {
    opacity: 0;
    z-index: 5;
}

.screen.leaving .screen-inner {
    animation: fadeSlideOut 0.4s ease forwards;
}

@keyframes fadeSlideOut {
    to { opacity: 0; transform: translateY(-30px) scale(0.96); }
}

/* ========== LOADING ========== */
.screen-loading {
    background: var(--bg);
    z-index: 100;
}

.loader-wrap {
    text-align: center;
}

.loader-ring {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(108, 92, 231, 0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loader-text {
    color: var(--hint);
    font-size: 14px;
}

/* ========== STEP BADGE ========== */
.step-badge {
    display: inline-block;
    padding: 6px 16px;
    background: rgba(108, 92, 231, 0.12);
    border: 1px solid rgba(108, 92, 231, 0.2);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-light);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 28px;
}

/* ========== HERO ICON ========== */
.hero-icon {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-icon span {
    font-size: 52px;
    position: relative;
    z-index: 2;
    animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.icon-glow {
    position: absolute;
    inset: -20px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(108, 92, 231, 0.3) 0%, transparent 70%);
    animation: glowPulse 3s ease-in-out infinite;
}

.icon-glow.glow-purple {
    background: radial-gradient(circle, rgba(139, 92, 246, 0.3) 0%, transparent 70%);
}

.icon-glow.glow-mod {
    background: radial-gradient(circle, rgba(99, 110, 114, 0.3) 0%, transparent 70%);
}

.icon-glow.glow-orange {
    background: radial-gradient(circle, rgba(245, 158, 11, 0.3) 0%, transparent 70%);
}

@keyframes glowPulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.15); opacity: 1; }
}

/* ========== TYPOGRAPHY ========== */
.screen-inner h1 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 10px;
    line-height: 1.2;
}

.screen-desc {
    color: var(--hint);
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 32px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

/* ========== BUTTONS ========== */
.btn-stack {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn-icon {
    font-size: 18px;
}

.btn-main {
    background: linear-gradient(135deg, #6c5ce7, #5a4bd1);
    color: white;
    box-shadow: 0 8px 28px rgba(108, 92, 231, 0.35);
}

.btn-main:active {
    box-shadow: 0 4px 16px rgba(108, 92, 231, 0.3);
}

.btn-main.btn-purple {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
    box-shadow: 0 8px 28px rgba(139, 92, 246, 0.35);
}

.btn-main.btn-orange {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    box-shadow: 0 8px 28px rgba(245, 158, 11, 0.35);
}

.btn-main.btn-green {
    background: linear-gradient(135deg, #10b981, #059669);
    box-shadow: 0 8px 28px rgba(16, 185, 129, 0.35);
}

.btn-outline {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-outline:active {
    background: rgba(255, 255, 255, 0.08);
}

/* ========== HINT TEXT ========== */
.hint-text {
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 12px;
    color: var(--orange);
    font-size: 13px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ========== INVITE PROGRESS ========== */
.invite-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.invite-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.invite-dot.filled {
    background: linear-gradient(135deg, var(--green), #059669);
    border-color: var(--green);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.invite-dot.filled::after {
    content: '✓';
    color: white;
    font-size: 16px;
    font-weight: 800;
}

.invite-count {
    color: var(--hint);
    font-size: 14px;
    margin-bottom: 24px;
}

.invite-count span {
    color: var(--green);
    font-weight: 700;
}

/* ========== REFERRAL BOX ========== */
.referral-box {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    margin-bottom: 20px;
    overflow: hidden;
}

.referral-link-display {
    flex: 1;
    padding: 14px 16px;
    font-size: 12px;
    color: var(--hint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.referral-copy-btn {
    padding: 14px 18px;
    background: rgba(108, 92, 231, 0.15);
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.referral-copy-btn:active {
    background: rgba(108, 92, 231, 0.3);
}

/* ========== DONE SCREEN ========== */
.done-animation {
    position: relative;
    margin-bottom: 20px;
}

.trophy {
    font-size: 80px;
    animation: trophyBounce 1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes trophyBounce {
    0% { transform: scale(0) rotate(-20deg); opacity: 0; }
    60% { transform: scale(1.2) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.done-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 24px 0 32px;
}

.done-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.done-stat-val {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.done-stat-lbl {
    font-size: 12px;
    color: var(--hint);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ========== BOTTOM BAR ========== */
.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 40px 24px;
    background: linear-gradient(to top, var(--bg) 60%, transparent);
    z-index: 50;
}

.bottom-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    max-width: 280px;
    margin: 0 auto;
}

.bottom-step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--hint);
    flex-shrink: 0;
    transition: all 0.4s ease;
}

.bottom-step.active {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(108, 92, 231, 0.12);
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.2);
}

.bottom-step.done {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.bottom-line {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.06);
    position: relative;
    overflow: hidden;
}

.bottom-line-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: var(--accent);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    padding: 12px 24px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    z-index: 200;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
    white-space: nowrap;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: rgba(16, 185, 129, 0.9);
    color: white;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
}

.toast.error {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

.toast.info {
    background: rgba(108, 92, 231, 0.9);
    color: white;
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.3);
}

/* ========== CONFETTI ========== */
.confetti-wrap {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    top: -10px;
    animation: confettiFall linear forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ========== WEBSITE LINK BOX ========== */
.website-link-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 14px;
    margin-bottom: 20px;
}

.website-link-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.website-link-url {
    font-size: 14px;
    color: var(--orange);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== MODERATION ========== */
.moderation-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    margin-bottom: 16px;
    text-align: left;
}

.mod-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--hint);
    line-height: 1.4;
}

.mod-row b {
    color: var(--text);
}

.mod-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* ========== RESPONSIVE ========== */
@media (max-height: 640px) {
    .hero-icon { width: 72px; height: 72px; margin-bottom: 16px; }
    .hero-icon span { font-size: 40px; }
    .screen-inner h1 { font-size: 22px; }
    .screen-desc { font-size: 14px; margin-bottom: 20px; }
    .invite-dot { width: 34px; height: 34px; }
}
