"""
DungeonMaster AI - HuggingFace Spaces Entry Point

This is the main entry point for the HuggingFace Spaces deployment.
It imports and launches the Gradio application from ui/app.py.
"""

import os
import sys

# Add the project root to the path for imports
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))

# Import and run the main application
from ui.app import create_app, main, load_custom_css, CRITICAL_HEAD_CSS
from ui.themes.fantasy_theme import fantasy_theme

if __name__ == "__main__":
    main()
else:
    # For Gradio Spaces, create the app object
    demo = create_app()
    
    # Gradio 6: Load custom CSS
    custom_css = load_custom_css()
    
    # Set CSS, theme, and head directly on the app (for Gradio 6 compatibility)
    if custom_css:
        demo.css = custom_css
    demo.theme = fantasy_theme
    demo.head = CRITICAL_HEAD_CSS
