import 'package:flutter/material.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';
import 'package:provider/provider.dart';

// [C] 공통 서비스
import 'package:service_api/service_api.dart';
// [A] 공통 UI 셸 (인트로 화면)
import 'package:feature_common/feature_common.dart'; 
// 🔽 [수정] 스도쿠 대신 수학 퀴즈 로비 임포트
import 'package:feature_game_mathquiz/feature_game_mathquiz.dart'; 

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await MobileAds.instance.initialize();

  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(
          create: (_) => ThemeNotifier(),
        ),
        ChangeNotifierProvider(
          create: (_) => SessionNotifier(),
        ),
      ],
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final themeData = context.select((ThemeNotifier n) => n.currentTheme);
    final darkThemeData = context.select((ThemeNotifier n) => n.currentDarkTheme);
    final themeMode = context.select((ThemeNotifier n) => n.currentThemeMode);

    return MaterialApp(
      title: '계산 퀴즈', // 👈 [수정]
      theme: themeData,
      darkTheme: darkThemeData,
      themeMode: themeMode,
      debugShowCheckedModeBanner: false, 

      home: IntroScreen(
        // 🔽 [수정]
        // Intro가 끝나면 MathQuizLobbyScreen으로 이동
        nextScreenBuilder: (context) => const MathQuizLobbyScreen(),
      ),
    );
  }
}