:root {
  --bg-deep: #031a1a;
  --bg-mid: #043230;
  --bg-teal: #007d79;
  --cyan: #00f5ff;
  --cyan-soft: rgba(0, 245, 255, 0.14);
  --cyan-border: rgba(0, 245, 255, 0.3);
  --card-bg: rgba(5, 34, 34, 0.84);
  --card-border: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(2, 20, 20, 0.72);
  --text-primary: #f4fbfb;
  --text-secondary: #9ac4c2;
  --text-muted: #6c9795;
  --danger: #ff6b7a;
  --danger-bg: rgba(255, 107, 122, 0.12);
  --radius-xl: 22px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-deep);
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: relative;
  overflow-x: hidden;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

/* Background inspired by the JuCoin teal banner & subtle diamond geometry */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(0, 125, 121, 0.52) 0%, rgba(3, 26, 26, 0) 65%),
    linear-gradient(180deg, #042b29 0%, #031a1a 55%, #021212 100%);
}

.bg-diamonds {
  position: absolute;
  inset: -40px;
  opacity: 0.14;
  background-image:
    linear-gradient(45deg, rgba(0, 245, 255, 0.16) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(0, 245, 255, 0.16) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(0, 245, 255, 0.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(0, 245, 255, 0.12) 75%);
  background-size: 96px 96px;
  background-position: 0 0, 0 48px, 48px -48px, -48px 0;
  mask-image: radial-gradient(circle at 50% 25%, #000 10%, transparent 75%);
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(72px);
}

.bg-glow--top {
  width: 340px;
  height: 240px;
  top: -90px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 245, 255, 0.18);
}

.bg-glow--bottom {
  width: 280px;
  height: 220px;
  bottom: -80px;
  right: -60px;
  background: rgba(0, 125, 121, 0.35);
}

/* Main Telegram Mini App container */
.app-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.brand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-logo__mark {
  width: 38px;
  height: 36px;
  filter: drop-shadow(0 0 14px rgba(0, 240, 240, 0.35));
}

.brand-logo__text {
  font-size: 1.48rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #ffffff;
}

.tg-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(0, 245, 255, 0.1);
  border: 1px solid rgba(0, 245, 255, 0.24);
}

.tg-badge__icon {
  width: 14px;
  height: 14px;
}

/* Hero */
.hero {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.hero__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px var(--cyan);
}

.hero__title {
  margin: 0;
  font-size: clamp(1.65rem, 6vw, 2rem);
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.accent {
  color: var(--cyan);
}

.hero__subtitle {
  margin: 0;
  font-size: 0.93rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* Auth Card */
.auth-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-xl);
  padding: 20px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow:
    0 20px 44px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Telegram User Chip */
.tg-user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: rgba(0, 245, 255, 0.08);
  border: 1px solid rgba(0, 245, 255, 0.22);
}

.tg-user-chip[hidden] {
  display: none;
}

.tg-user-chip__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #031a1a;
  background: var(--cyan);
  flex-shrink: 0;
}

.tg-user-chip__info {
  min-width: 0;
  flex: 1;
}

.tg-user-chip__name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tg-user-chip__handle {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.tg-user-chip__verified {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--cyan);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 245, 255, 0.12);
}

/* Password field (for 2FA) */
.password-wrap {
  position: relative;
}

.field__input--password {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--cyan);
}

.icon-eye {
  width: 18px;
  height: 18px;
}

/* Infinite Sync View */
.sync-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px 8px 12px;
}

.sync-view[hidden] {
  display: none;
}

.sync-spinner {
  position: relative;
  width: 68px;
  height: 68px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
}

.sync-spinner__ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(0, 240, 240, 0.14);
  border-top-color: #00f0f0;
  border-right-color: #00f0f0;
  animation: jucoin-spin 0.9s linear infinite;
}

.sync-spinner__core {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 240, 240, 0.2);
  box-shadow: 0 0 18px rgba(0, 240, 240, 0.45);
  animation: jucoin-pulse 1.5s ease-in-out infinite;
}

.sync-view__title {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 700;
}

.sync-view__desc {
  margin: 0 0 18px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.sync-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(0, 240, 240, 0.08);
  border: 1px solid rgba(0, 240, 240, 0.22);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--cyan);
}

.sync-badge__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  animation: jucoin-pulse 1.2s ease-in-out infinite;
}

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

@keyframes jucoin-pulse {
  0%, 100% {
    opacity: 0.45;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

/* Form */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form[hidden] {
  display: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field__label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field__input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  letter-spacing: 0.01em;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field__input::placeholder {
  color: var(--text-muted);
}

.field__input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 255, 0.14);
}

.field__hint {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Code step header */
.code-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-md);
  background: rgba(2, 18, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.code-target__text {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-secondary);
}

.code-target__text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* 5-digit OTP group */
.otp-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.otp-input {
  width: 100%;
  height: 54px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--input-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.otp-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 245, 255, 0.16);
}

.resend-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 22px;
}

.resend-timer {
  font-size: 0.79rem;
  color: var(--text-muted);
}

.text-link {
  padding: 0;
  border: none;
  background: transparent;
  color: var(--cyan);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}

.text-link:hover {
  text-decoration: underline;
}

.text-link[hidden],
.resend-timer[hidden] {
  display: none;
}

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-bg);
  border: 1px solid rgba(255, 107, 122, 0.35);
  color: #ffb0b8;
  font-size: 0.83rem;
  line-height: 1.4;
}

.form-error[hidden] {
  display: none;
}

/* Buttons */
.btn {
  width: 100%;
  height: 48px;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.14s ease, filter 0.16s ease, background-color 0.16s ease;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn__icon {
  width: 19px;
  height: 19px;
}

.btn--telegram {
  color: #022020;
  background: linear-gradient(135deg, #00f5ff 0%, #26e3d8 100%);
  box-shadow: 0 10px 24px rgba(0, 245, 255, 0.24);
}

.btn--telegram:hover {
  filter: brightness(1.05);
}

.btn--primary {
  color: #ffffff;
  background: linear-gradient(135deg, #008c87 0%, #006c68 100%);
  border: 1px solid rgba(0, 245, 255, 0.28);
}

.btn--primary:hover {
  filter: brightness(1.08);
}

.btn--ghost {
  margin-top: 10px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Auth Success View */
.auth-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 8px 0 4px;
}

.auth-success[hidden] {
  display: none;
}

.auth-success__icon {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #031a1a;
  background: var(--cyan);
  box-shadow: 0 0 28px rgba(0, 245, 255, 0.35);
  margin-bottom: 14px;
}

.auth-success__icon svg {
  width: 28px;
  height: 28px;
}

.auth-success__title {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 700;
}

.auth-success__desc {
  margin: 0 0 18px;
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

.session-box {
  width: 100%;
  border-radius: var(--radius-md);
  background: rgba(2, 18, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.session-box__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.session-box__row strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Features strip */
.features {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feature-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(5, 34, 34, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.feature-card__icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--cyan);
  background: var(--cyan-soft);
  border: 1px solid rgba(0, 245, 255, 0.22);
}

.feature-card__icon svg {
  width: 19px;
  height: 19px;
}

.feature-card__title {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 700;
}

.feature-card__text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

/* Footer */
.footer {
  text-align: center;
  padding-top: 4px;
}

.footer p {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
}

button,
input {
  touch-action: manipulation;
}

@media (max-width: 375px) {
  body {
    padding-left: 12px;
    padding-right: 12px;
  }
  .auth-card {
    padding: 16px;
    border-radius: 18px;
  }
  .otp-group {
    gap: 6px;
  }
  .otp-input {
    height: 48px;
    font-size: 1.2rem;
  }
}
