import SwiftUI

struct MainMenuView: View {
    @ObservedObject private var progress = ProgressStore.shared
    @State private var showLevelSelect = false

    var body: some View {
        ZStack {
            Color(hex: "#1A1A2E").ignoresSafeArea()

            VStack(spacing: 40) {
                Spacer()

                VStack(spacing: 8) {
                    Text("COLLAPSE")
                        .font(.system(size: 46, weight: .black, design: .rounded))
                        .foregroundColor(.white)
                    Text("LOGIC")
                        .font(.system(size: 46, weight: .black, design: .rounded))
                        .foregroundColor(Color(hex: "#457B9D"))
                }

                Text("Push. Collide. Destroy.")
                    .font(.system(size: 16, weight: .medium, design: .rounded))
                    .foregroundColor(.white.opacity(0.5))

                Spacer()

                Button {
                    showLevelSelect = true
                } label: {
                    Text("PLAY")
                        .font(.system(size: 20, weight: .bold, design: .rounded))
                        .foregroundColor(.white)
                        .frame(width: 200, height: 56)
                        .background(Color(hex: "#E63946"))
                        .clipShape(RoundedRectangle(cornerRadius: 16))
                }

                let total = ProgressStore.shared.totalStars()
                if total > 0 {
                    Text("⭐ \(total) stars collected")
                        .font(.system(size: 14, design: .rounded))
                        .foregroundColor(.white.opacity(0.4))
                }

                Spacer()
            }
            .padding(.horizontal, 32)
        }
        .fullScreenCover(isPresented: $showLevelSelect) {
            LevelSelectView()
        }
    }
}
