<!doctype html>
<html lang="ru">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
    <meta name="theme-color" content="#111018" />
    <link rel="manifest" href="/manifest.webmanifest" />
    <link rel="icon" href="/icon.svg" type="image/svg+xml" />
    <meta name="description" content="Закрытый книжный клуб для друзей" />
    <title>Крутышки — книжный клуб</title>
    <style>
      html,body{margin:0;min-height:100%;background:#111018;color:#f5f0eb;font-family:Arial,sans-serif}
      #boot-status{min-height:100vh;display:grid;place-content:center;text-align:center;padding:28px;box-sizing:border-box}
      #boot-status h1{font-family:Georgia,serif;font-weight:500;color:#e0c397}
      #boot-status p{max-width:340px;color:#c5bac7;font-size:14px;line-height:1.6}
    </style>
    <script>
      // Show the actual startup failure instead of leaving an endless loading screen.
      window.addEventListener("error", (event) => {
        const status = document.querySelector("#boot-status p");
        if (status && event.target && event.target.tagName === "SCRIPT") {
          status.textContent = "Не удалось загрузить файл приложения: " + (event.target.src || "JavaScript");
        } else if (status && event.message) {
          status.textContent = "Ошибка запуска приложения: " + event.message;
        }
      }, true);
      window.addEventListener("unhandledrejection", (event) => {
        const status = document.querySelector("#boot-status p");
        if (status) status.textContent = "Ошибка запуска приложения: " + String(event.reason);
      });
      // Remove any older PWA cache that may be serving an outdated entry bundle.
      window.addEventListener("load", () => {
        if ("serviceWorker" in navigator) {
          navigator.serviceWorker.getRegistrations()
            .then((registrations) => Promise.all(registrations.map((registration) => registration.unregister())))
            .catch((error) => console.warn("Could not clear old service workers", error));
        }
        if ("caches" in window) {
          caches.keys()
            .then((keys) => Promise.all(keys.map((key) => caches.delete(key))))
            .catch((error) => console.warn("Could not clear old app caches", error));
        }
      });
      window.setTimeout(() => {
        const status = document.querySelector("#boot-status p");
        if (status && status.textContent === "Загружаем приложение…") status.textContent = "JavaScript приложения не запустился. Перезагрузите страницу; если ошибка повторится, сообщите нам.";
      }, 12000);
    </script>
    <script type="module" crossorigin src="/assets/index-C0Rr_0Xs.js"></script>
    <link rel="stylesheet" crossorigin href="/assets/index-D3bYG8BH.css">
  </head>
  <body>
    <div id="root">
      <div id="boot-status"><h1>Крутышки</h1><p>Загружаем приложение…</p></div>
    </div>
  </body>
</html>