.tg-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
}

.tg-auth-overlay.is-open {
  display: flex;
}

.tg-auth-modal {
  position: relative;
  width: 100%;
  max-width: 480px;
  padding: 36px 32px 30px;
  border-radius: 16px;
  background: #1c2533;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  color: #fff;
  animation: tg-auth-in 0.22s ease;
}

@keyframes tg-auth-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.tg-auth-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8b98a8;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.tg-auth-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}

.tg-auth-logo {
  width: 112px;
  height: 112px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #2aabee, #229ed9);
  color: #fff;
}

.tg-auth-logo svg {
  width: 56px;
  height: 56px;
  display: block;
  fill: #fff;
  color: #fff;
}

.tg-auth-title {
  margin: 0 0 12px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
}

.tg-auth-text {
  margin: 0 0 26px;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #9aa7b5;
}

.tg-auth-field {
  position: relative;
  margin-bottom: 20px;
}

.tg-auth-field input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: 60px;
  padding: 20px 16px 10px;
  border: 1.5px solid #2aabee;
  border-radius: 12px;
  background: transparent;
  color: #fff;
  font-size: 1.12rem;
  letter-spacing: 0.02em;
  outline: none;
}

.tg-auth-field input:focus {
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.18);
}

.tg-auth-field input.is-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.tg-auth-field label {
  position: absolute;
  left: 14px;
  top: 8px;
  z-index: 1;
  font-size: 0.74rem;
  color: #2aabee;
  pointer-events: none;
}

.tg-auth-phone-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.tg-auth-country-select {
  flex: 0 0 5.4rem;
  width: 5.4rem;
  min-width: 5.4rem;
  max-width: 5.4rem;
  height: 60px;
  padding: 0 1.35rem 0 0.55rem;
  border: 1.5px solid #2aabee;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(42, 171, 238, 0.9) 50%),
    linear-gradient(135deg, rgba(42, 171, 238, 0.9) 50%, transparent 50%);
  background-position:
    calc(100% - 11px) calc(50% - 2px),
    calc(100% - 7px) calc(50% - 2px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.tg-auth-country-select option {
  color: #111;
  background: #fff;
  font-weight: 600;
}

.tg-auth-phone-row input {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  font-size: 1.12rem;
  letter-spacing: 0.02em;
}

.tg-auth-submit {
  position: relative;
  width: 100%;
  height: 56px;
  border: 0;
  border-radius: 12px;
  background: #2aabee;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.tg-auth-submit:hover:not(:disabled) {
  background: #229ed9;
}

.tg-auth-submit:disabled {
  opacity: 0.75;
  cursor: wait;
}

.tg-auth-submit-spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  animation: tg-auth-spin 0.75s linear infinite;
  flex-shrink: 0;
}

.tg-auth-submit-spinner[hidden] {
  display: none !important;
}

.tg-auth-submit-label[hidden] {
  display: none !important;
}

.tg-auth-loading-hint {
  margin: 0 0 16px;
  color: #9aa7b5;
  font-size: 0.88rem;
  line-height: 1.45;
  text-align: center;
}

.tg-auth-error {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #ffb4b4;
  font-size: 0.82rem;
  text-align: center;
}

.tg-auth-wait {
  text-align: center;
  padding: 8px 0 4px;
}

.tg-auth-wait-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 3px solid rgba(42, 171, 238, 0.2);
  border-top-color: #2aabee;
  animation: tg-auth-spin 0.9s linear infinite;
}

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

.tg-auth-wait h3 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.tg-auth-wait p {
  margin: 0 0 20px;
  color: #9aa7b5;
  font-size: 0.88rem;
  line-height: 1.45;
}

.tg-auth-wait-ok {
  width: 100%;
  max-width: 200px;
  margin: 0 auto;
}

.tg-auth-step {
  display: none;
}

.tg-auth-step.is-active {
  display: block;
}

@media (max-width: 480px) {
  .tg-auth-overlay {
    align-items: flex-end;
    padding: 12px;
  }

  .tg-auth-modal {
    max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
}
