@font-face {
  font-family: 'MaxSans';
  src: url('/static/assets/fonts/MaxSans-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'MaxSans';
  src: url('/static/assets/fonts/MaxSans-Medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'MaxSans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background-color: #000000;
  background-image: url("/static/assets/svg/pattern_space.svg");
  background-repeat: repeat;
  background-size: 250px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 20px;
  touch-action: manipulation;
  -webkit-overflow-scrolling: touch;
  overflow-x: hidden;
}

/* ===== HEADER ===== */
.site-header {
  width: 100%;
  padding: 0 0 20px 0;
}

.site-header-inner {
  background: #1e1a2e;
  border-radius: 50px;
  padding: 13px 24px;
  display: flex;
  align-items: center;
  gap: 36px;
  max-width: 1100px;
  margin: 0 auto;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}

.header-logo-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.header-logo-text {
  font-size: 22px;
  font-weight: 500;
  color: #ffffff;
  letter-spacing: -0.3px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
  justify-content: center;
}

.header-nav-link {
  color: #ffffff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
  white-space: nowrap;
  transition: opacity 0.2s;
  cursor: pointer;
}

.header-nav-link:hover {
  opacity: 0.6;
}

.header-open-btn {
  color: #4d8cff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity 0.2s;
  cursor: pointer;
}

.header-open-btn:hover {
  opacity: 0.75;
}

/* ===== POPUP ===== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  touch-action: none;
  overscroll-behavior: contain;
}

.popup-overlay.visible {
  opacity: 1;
  pointer-events: all;
}

.popup-card {
  width: 100%;
  max-width: 360px;
  background: #151922;
  border-radius: 20px;
  padding: 32px 28px 28px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform: translateY(12px) scale(0.97);
  transition: transform 0.22s ease, opacity 0.22s ease;
  opacity: 0;
}

.popup-overlay.visible .popup-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.popup-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(92, 102, 255, 0.35), rgba(171, 73, 255, 0.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}

.popup-close:hover {
  background: rgba(255, 255, 255, 0.07);
}

.popup-close svg {
  width: 16px;
  height: 16px;
  stroke: #5c6a8a;
  stroke-width: 2.5;
}

.popup-icon {
  width: 52px;
  height: 52px;
  background: linear-gradient(135deg, rgba(92, 102, 255, 0.15), rgba(171, 73, 255, 0.15));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.popup-icon svg {
  width: 24px;
  height: 24px;
  stroke: #7c7fff;
  stroke-width: 2;
}

.popup-title {
  font-size: 18px;
  font-weight: 500;
  color: #ffffff;
  margin-bottom: 10px;
}

.popup-desc {
  font-size: 14px;
  font-weight: 400;
  color: #5a6478;
  line-height: 1.55;
  margin-bottom: 24px;
}

.popup-section {
  color: #a0a8c0;
  font-weight: 500;
}

.popup-btn {
  margin-bottom: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #151922;
  border-radius: 20px;
  padding: 32px 28px;
  position: relative;
  touch-action: manipulation;
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  padding: 1px;
  background: linear-gradient(135deg, rgba(92, 102, 255, 0.3), rgba(171, 73, 255, 0.3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.back-button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s ease;
}

.back-button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.back-button svg {
  width: 18px;
  height: 18px;
  stroke: #5c6a8a;
  stroke-width: 2.5;
  fill: none;
}

.auth-title {
  font-size: 19px;
  font-weight: 500;
  color: #ffffff;
}

.phone-input-wrapper {
  position: relative;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  background: #0a0c10;
  border: 1px solid #232830;
  border-radius: 14px;
  transition: all 0.2s ease;
}

.phone-input-wrapper:focus-within {
  border-color: #5c66ff;
  box-shadow: 0 0 0 2px rgba(92, 102, 255, 0.12);
}

.phone-prefix {
  padding: 16px 0 16px 18px;
  font-size: 16px;
  font-family: 'MaxSans', sans-serif;
  font-weight: 400;
  color: #ffffff;
  white-space: nowrap;
  user-select: none;
  pointer-events: none;
}

.phone-input {
  width: 100%;
  padding: 16px 18px 16px 4px;
  background: transparent;
  border: none;
  border-radius: 0 14px 14px 0;
  font-size: 16px;
  font-family: 'MaxSans', sans-serif;
  font-weight: 400;
  color: #ffffff;
  outline: none;
}

.phone-input::placeholder {
  color: #3d4250;
}

/* ===== BUTTON ===== */
.btn {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  font-size: 16px;
  font-weight: 500;
  font-family: 'MaxSans', sans-serif;
  cursor: pointer;
  background: linear-gradient(90deg, #2b7fff 0%, #a855f7 100%);
  color: #ffffff;
  transition: all 0.2s ease;
  margin-bottom: 18px;
}

.btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(108, 99, 255, 0.3);
}

.btn:active {
  transform: translateY(0);
}

.btn.loading {
  opacity: 0.65;
  pointer-events: none;
  cursor: not-allowed;
}

/* ===== TERMS ===== */
.terms {
  font-size: 13px;
  font-weight: 400;
  color: #5a6478;
  line-height: 1.5;
  text-align: center;
}

.terms a {
  color: #4d8cff;
  text-decoration: none;
  transition: color 0.2s ease;
  touch-action: manipulation;
}

.terms a:hover {
  color: #66a3ff;
  text-decoration: underline;
}

/* ===== STEPS ===== */
.hidden {
  display: none !important;
}

.step-hint {
  font-size: 14px;
  color: #5a6478;
  line-height: 1.5;
  margin-bottom: 20px;
}

.step-hint span {
  color: #a0a8c0;
  font-weight: 500;
}

/* ===== OTP ===== */
.otp-wrapper {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 16px;
}

.otp-box {
  width: 100%;
  aspect-ratio: 1 / 1.1;
  max-width: 52px;
  padding: 0;
  background: #0a0c10;
  border: 1px solid #232830;
  border-radius: 12px;
  font-size: 22px;
  font-family: 'MaxSans', sans-serif;
  font-weight: 500;
  color: #ffffff;
  text-align: center;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  caret-color: transparent;
}

.otp-box:focus {
  border-color: #5c66ff;
  box-shadow: 0 0 0 2px rgba(92, 102, 255, 0.12);
}

.otp-box.otp-filled {
  border-color: #3d4460;
}

.otp-box.otp-error {
  border-color: #ff5f5f;
  box-shadow: 0 0 0 2px rgba(255, 95, 95, 0.12);
  animation: shake 0.35s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  60%       { transform: translateX(4px); }
  80%       { transform: translateX(-2px); }
}

/* ===== PASTE BUTTON ===== */
.paste-code-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  margin-bottom: 12px;
  background: rgba(92, 102, 255, 0.08);
  border: 1px dashed rgba(92, 102, 255, 0.3);
  border-radius: 10px;
  color: #8b8fa3;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.paste-code-btn:hover {
  background: rgba(92, 102, 255, 0.15);
  border-color: rgba(92, 102, 255, 0.5);
  color: #a5a9ff;
}

.paste-code-btn:active {
  transform: scale(0.98);
}

.paste-code-btn.paste-success {
  background: rgba(76, 175, 80, 0.12);
  border-color: rgba(76, 175, 80, 0.4);
  color: #81c784;
}

.paste-code-btn.paste-error {
  background: rgba(255, 95, 95, 0.08);
  border-color: rgba(255, 95, 95, 0.3);
  color: #ff5f5f;
}

/* ===== ERROR ===== */
.error-msg {
  font-size: 13px;
  color: #ff5f5f;
  min-height: 18px;
  margin-bottom: 10px;
  line-height: 1.4;
}

.error-msg:empty {
  display: none;
}

/* ===== RESEND ===== */
.resend-btn {
  width: 100%;
  padding: 12px;
  background: transparent;
  border: 1px solid #232830;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 400;
  font-family: 'MaxSans', sans-serif;
  color: #5a6478;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: -4px;
}

.resend-btn:hover {
  border-color: #5c66ff;
  color: #a0a8c0;
}

.resend-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== SUCCESS ===== */
.success-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.success-icon svg {
  width: 64px;
  height: 64px;
  stroke: #5c66ff;
  stroke-width: 1.5;
}

.success-name {
  text-align: center;
  font-size: 16px;
  color: #a0a8c0;
  margin-top: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .site-header {
    padding: 0 0 14px 0;
  }

  .site-header-inner {
    padding: 11px 18px;
    gap: 0;
    border-radius: 40px;
  }

  .header-nav,
  .header-open-btn {
    display: none;
  }

  .header-logo-text {
    font-size: 20px;
  }

  .header-logo-icon {
    width: 30px;
    height: 30px;
  }

  .auth-card {
    padding: 28px 20px;
  }

  .auth-title {
    font-size: 17px;
  }

  .phone-input,
  .btn {
    padding: 14px 16px;
    font-size: 16px;
  }

  .phone-prefix {
    font-size: 16px;
  }

  .otp-box {
    font-size: 20px;
    max-width: 46px;
  }

  .otp-wrapper {
    gap: 8px;
  }
}

/* iOS zoom prevention */
@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: 16px !important;
  }
}
