:root {
  --bg: #f8f8f8;
  --card: #ffffff;
  --text: #111111;
  --muted: #4d4d4d;
  --line: #d3d3d3;
  --soft-line: #e5e5e5;
  --brand: #6260a8;
  --brand-hover: #525095;
  --focus: rgba(98, 96, 168, 0.24);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-family, "Segoe UI", Arial, sans-serif);
}

button,
a {
  font: inherit;
}

.page-shell {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 20px 92px;
}

.join-card {
  width: min(100%, 420px);
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 32px 32px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.brand-tile {
  width: 100px;
  height: 100px;
  display: grid;
  place-items: center;
  margin-bottom: 34px;
  background: #ffffff;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.brand-tile img {
  max-width: 72%;
  max-height: 72%;
  object-fit: contain;
}

.logo-placeholder {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  border-radius: 14px;
  background: linear-gradient(145deg, #8b8af5, var(--brand));
}

.join-card h1 {
  margin: 0 0 36px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  text-align: center;
}

.actions {
  width: 100%;
  display: grid;
  gap: 8px;
}

.btn {
  min-height: 42px;
  width: 100%;
  padding: 10px 18px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:focus-visible,
.download-block a:focus-visible,
.footer a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  color: #ffffff;
  background: var(--brand);
  box-shadow: var(--shadow);
}

.btn-primary:hover {
  background: var(--brand-hover);
}

.btn-secondary {
  color: #111111;
  background: #ffffff;
  border-color: #d8d8d8;
  box-shadow: var(--shadow);
}

.btn-secondary:hover {
  background: #f7f7f7;
  border-color: #c5c5c5;
}

.download-block {
  margin-top: 26px;
  text-align: center;
  font-size: 14px;
  line-height: 1.35;
}

.mini-logo {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  margin: 0 auto 9px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 6px;
  background: linear-gradient(145deg, #8b8af5, var(--brand));
}

.download-block p {
  margin: 0;
}

.download-block a,
.footer a {
  color: #4038d3;
  text-decoration: none;
}

.download-block a:hover,
.footer a:hover {
  text-decoration: underline;
}

.footer {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 14px 20px 24px;
  color: var(--muted);
  font-size: 12px;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.footer-mark {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 3px;
  background: var(--brand);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(1px);
}

.modal-overlay[hidden],
.loading-stage[hidden],
.fallback-modal[hidden] {
  display: none;
}

.loading-stage {
  display: grid;
  justify-items: center;
  gap: 14px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 600;
}

.loading-stage p {
  margin: 0;
}

.spinner {
  width: 42px;
  height: 42px;
  display: inline-block;
  border: 4px solid rgba(255, 255, 255, 0.36);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 820ms linear infinite;
}

.fallback-modal {
  position: relative;
  width: min(100%, 430px);
  padding: 34px 32px 30px;
  color: var(--text);
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  color: #5f5f5f;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.modal-close:hover {
  background: #f0f0f0;
}

.modal-icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 18px;
  background: linear-gradient(145deg, #f2f1ff, #ffffff);
  border: 1px solid #e7e6fb;
}

.spinner-small {
  width: 30px;
  height: 30px;
  border-width: 3px;
  border-color: rgba(98, 96, 168, 0.22);
  border-top-color: var(--brand);
}

.fallback-modal h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.25;
  font-weight: 700;
}

.modal-copy {
  margin: 0 auto 22px;
  max-width: 340px;
  color: #454545;
  font-size: 14px;
  line-height: 1.5;
}

.download-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  margin-bottom: 18px;
  padding: 10px 14px;
  color: #27235f;
  background: #f4f3ff;
  border: 1px solid #e1dfff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.spinner-tiny {
  width: 18px;
  height: 18px;
  border-width: 2px;
  border-color: rgba(98, 96, 168, 0.22);
  border-top-color: var(--brand);
}

.setup-help {
  margin: 0 0 14px;
  color: #555555;
  font-size: 13px;
  line-height: 1.45;
}

.modal-action {
  min-height: 40px;
}

body.modal-open {
  overflow: hidden;
}

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

@media (max-width: 560px) {
  .page-shell {
    min-height: auto;
    padding: 28px 16px 34px;
    justify-content: flex-start;
  }

  .join-card {
    min-height: 0;
    padding: 38px 24px 26px;
    border-radius: 8px;
  }

  .brand-tile {
    width: 86px;
    height: 86px;
    margin-bottom: 28px;
  }

  .join-card h1 {
    margin-bottom: 30px;
    font-size: 19px;
  }

  .btn {
    min-height: 44px;
    font-size: 14px;
  }

  .footer {
    align-items: center;
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px 22px;
    text-align: center;
  }

  .fallback-modal {
    padding: 32px 22px 24px;
  }

  .fallback-modal h2 {
    font-size: 20px;
  }
}

@media (max-width: 360px) {
  .page-shell {
    padding-inline: 12px;
  }

  .join-card {
    padding-inline: 18px;
  }
}
