.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background:
    radial-gradient(ellipse 70% 55% at 50% 0%, rgba(168, 85, 247, 0.22), transparent 58%),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(0, 255, 159, 0.12), transparent 55%),
    rgba(2, 4, 10, 0.88);
  backdrop-filter: blur(14px);
  animation: ssModalFadeIn 220ms ease;
}

.modal {
  position: relative;
  width: min(420px, 100%);
  max-width: 95vw;
  padding: 28px 26px 22px;
  border-radius: 22px;
  border: 1px solid rgba(0, 245, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 72px),
    linear-gradient(155deg, rgba(8, 12, 24, 0.98), rgba(18, 8, 28, 0.96));
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.05) inset,
    0 0 48px rgba(255, 0, 255, 0.14);
  animation: ssModalPopIn 260ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.modal::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, #00ff9f, #00f5ff, #ff00ff);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(235, 244, 255, 0.9);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.modal-close:hover,
.modal-close:focus-visible {
  border-color: rgba(0, 245, 255, 0.45);
  background: rgba(0, 245, 255, 0.12);
  outline: none;
  transform: scale(1.04);
}

.modal-brand {
  position: relative;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
}

.modal-brand__mark {
  position: relative;
  z-index: 1;
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  overflow: hidden;
}

.modal-brand__image {
  width: 52px;
  height: 52px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(255, 0, 255, 0.35));
}

.modal-brand__glow {
  position: absolute;
  inset: -8px;
  border-radius: 22px;
  background: radial-gradient(circle, rgba(0, 255, 159, 0.28), transparent 68%);
  filter: blur(8px);
  animation: ssModalGlow 2.8s ease-in-out infinite;
}

.modal-eyebrow {
  margin: 0 0 4px;
  text-align: center;
  color: rgba(0, 255, 159, 0.88);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal h2 {
  margin: 0 0 8px;
  text-align: center;
  color: #f8fbff;
  font-size: clamp(1.35rem, 2vw + 0.8rem, 1.65rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.modal-hint {
  margin: 0 0 18px;
  text-align: center;
  color: rgba(196, 220, 244, 0.78);
  font-size: 0.9rem;
  line-height: 1.5;
}

.modal-form {
  display: grid;
  gap: 0;
}

.modal input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  margin-bottom: 12px;
  border-radius: 14px;
  border: 1px solid rgba(160, 227, 255, 0.2);
  background: rgba(0, 0, 0, 0.34);
  color: #f3f7ff;
  font-size: 0.96rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.modal input::placeholder {
  color: rgba(196, 220, 244, 0.45);
}

.modal input:focus {
  border-color: rgba(255, 0, 255, 0.5);
  background: rgba(8, 10, 18, 0.92);
  box-shadow: 0 0 0 3px rgba(255, 0, 255, 0.12);
}

.register-mode-choice {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
  padding: 0;
  border: 0;
}

.register-mode-choice legend {
  margin-bottom: 4px;
  color: rgba(154, 216, 255, 0.92);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.register-mode-choice label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 12px;
  border: 1px solid rgba(0, 245, 255, 0.2);
  border-radius: 14px;
  background: rgba(0, 245, 255, 0.05);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.register-mode-choice label:hover {
  border-color: rgba(0, 255, 159, 0.38);
  background: rgba(0, 255, 159, 0.08);
}

.register-mode-choice input {
  width: auto;
  min-height: auto;
  margin: 3px 0 0;
  padding: 0;
}

.register-mode-choice span {
  display: grid;
  gap: 3px;
}

.register-mode-choice strong {
  color: #effcff;
  font-size: 0.9rem;
}

.register-mode-choice small {
  color: rgba(224, 244, 255, 0.68);
  line-height: 1.35;
  font-size: 0.8rem;
}

.modal-password-field {
  position: relative;
  margin-bottom: 12px;
}

.modal-password-field input {
  margin-bottom: 0;
  padding-right: 48px;
}

.modal-password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  display: inline-flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(154, 216, 255, 0.1);
  color: #9ad8ff;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background 160ms ease;
}

.modal-password-toggle:hover,
.modal-password-toggle:focus-visible {
  background: rgba(154, 216, 255, 0.2);
  outline: 2px solid rgba(154, 216, 255, 0.35);
  outline-offset: 2px;
}

.modal-password-toggle__icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.modal-password-toggle__icon--off,
.modal-password-toggle.is-visible .modal-password-toggle__icon--eye {
  display: none;
}

.modal-password-toggle.is-visible .modal-password-toggle__icon--off {
  display: block;
}

.modal button[type="submit"],
.modal-submit {
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  background: linear-gradient(110deg, #00ff9f, #00f5ff 48%, #ff00ff);
  color: #050508;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  margin-bottom: 10px;
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.35),
    0 0 28px rgba(0, 255, 159, 0.22);
  transition: transform 160ms ease, filter 160ms ease, box-shadow 160ms ease;
}

.modal button[type="submit"]:hover,
.modal-submit:hover,
.modal button[type="submit"]:focus-visible,
.modal-submit:focus-visible {
  filter: brightness(1.05);
  transform: translateY(-1px);
  outline: none;
}

.modal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  margin-top: 2px;
  margin-bottom: 4px;
  text-align: center;
}

.modal-links a {
  color: rgba(184, 220, 255, 0.88);
  font-size: 0.86rem;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.modal-links a:hover,
.modal-links a:focus-visible {
  color: #00ff9f;
  text-decoration: underline;
  outline: none;
}

.modal-links-sep {
  color: rgba(200, 220, 255, 0.35);
  user-select: none;
}

.modal-error {
  min-height: 18px;
  margin-top: 8px;
  color: #ff7b9a;
  font-size: 0.88rem;
  text-align: center;
}

.auth-puzzle {
  margin: 2px 0 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(0, 245, 255, 0.28);
  background:
    linear-gradient(155deg, rgba(8, 14, 30, 0.86), rgba(7, 8, 20, 0.9)),
    radial-gradient(circle at 12% 4%, rgba(0, 245, 255, 0.16), transparent 48%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.auth-puzzle__head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.auth-puzzle__head strong {
  color: #dff9ff;
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-puzzle__badge {
  min-height: 20px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 159, 0.42);
  background: rgba(0, 255, 159, 0.12);
  color: #b9ffe3;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-puzzle__refresh {
  margin-left: auto;
  border: 1px solid rgba(154, 216, 255, 0.32);
  border-radius: 999px;
  background: rgba(154, 216, 255, 0.08);
  color: rgba(220, 242, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
}

.auth-puzzle__hint {
  margin: 0 0 8px;
  color: rgba(196, 220, 244, 0.78);
  font-size: 0.78rem;
}

.auth-puzzle__track {
  position: relative;
  width: 100%;
  height: 50px;
  border-radius: 12px;
  overflow: hidden;
  background:
    linear-gradient(132deg, rgba(0, 245, 255, 0.16), rgba(255, 0, 255, 0.12)),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.08),
      rgba(255, 255, 255, 0.08) 8px,
      rgba(255, 255, 255, 0.03) 8px,
      rgba(255, 255, 255, 0.03) 16px
    ),
    rgba(4, 14, 24, 0.94);
  border: 1px solid rgba(0, 245, 255, 0.18);
}

.auth-puzzle__target,
.auth-puzzle__piece {
  position: absolute;
  top: 7px;
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.auth-puzzle__target {
  border: 1px dashed rgba(255, 255, 255, 0.44);
  background: rgba(0, 0, 0, 0.25);
}

.auth-puzzle__piece {
  left: 0;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background:
    linear-gradient(130deg, rgba(0, 255, 159, 0.7), rgba(0, 245, 255, 0.78) 48%, rgba(255, 0, 255, 0.7));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  transition: left 120ms ease;
}

.auth-puzzle__slider {
  position: relative;
  margin-top: 8px;
  width: 100%;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(0, 245, 255, 0.2);
  background: rgba(4, 16, 28, 0.85);
}

.auth-puzzle__fill {
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(95deg, rgba(0, 255, 159, 0.34), rgba(0, 245, 255, 0.32), rgba(255, 0, 255, 0.24));
  transition: width 100ms linear;
  pointer-events: none;
}

.auth-puzzle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #00ff9f, #00f5ff, #ff00ff);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.36);
  cursor: grab;
}

.auth-puzzle__knob:active {
  cursor: grabbing;
}

.auth-puzzle__status {
  margin: 8px 0 0;
  font-size: 0.76rem;
  color: rgba(206, 233, 255, 0.85);
}

.auth-puzzle.is-solved .auth-puzzle__status {
  color: #66f7b5;
}

.auth-puzzle.is-error .auth-puzzle__status {
  color: #ff98ad;
}

.auth-puzzle.is-loading .auth-puzzle__refresh {
  opacity: 0.62;
  pointer-events: none;
}

@keyframes ssModalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes ssModalPopIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes ssModalGlow {
  0%,
  100% {
    opacity: 0.55;
    transform: scale(0.96);
  }

  50% {
    opacity: 1;
    transform: scale(1.04);
  }
}

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

  .modal {
    width: 100%;
    max-width: none;
    border-radius: 22px 22px 0 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .modal h2 {
    font-size: 1.28rem;
  }

  .modal input {
    min-height: 46px;
    font-size: 16px;
  }

  .modal button[type="submit"],
  .modal-submit {
    min-height: 48px;
  }
}
