:root {
  --ds-base: #111111;
  --ds-surface: rgba(22, 22, 22, 0.94);
  --ds-border: rgba(255, 255, 255, 0.1);
  --ds-text: rgba(255, 255, 255, 0.92);
  --ds-muted: rgba(255, 255, 255, 0.55);
  --brand-gold: #a8a8ae;
  --brand-gold-soft: rgba(168, 168, 174, 0.18);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body.auth-page {
  font-family: var(--font-site);
  background: var(--ds-base);
  color: var(--ds-text);
  -webkit-font-smoothing: antialiased;
}

.auth-screen {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 40px;
  overflow: hidden;
}

.auth-back {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ds-text);
  background: rgba(12, 12, 14, 0.75);
  border: 1px solid var(--ds-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.auth-logo {
  position: relative;
  z-index: 20;
  margin-bottom: 24px;
  line-height: 0;
  text-decoration: none;
}

.auth-logo img {
  height: clamp(44px, 8vw, 56px);
  width: auto;
  display: block;
}

.auth-panel {
  position: relative;
  z-index: 20;
  width: 100%;
  max-width: 420px;
  padding: 32px 28px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: var(--ds-surface);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  animation: auth-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-panel h1 {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
}

.auth-sub {
  text-align: center;
  font-size: 12px;
  color: var(--ds-muted);
  margin: 0 0 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.btn:hover { opacity: 0.92; transform: translateY(-1px); }

.btn-oauth {
  margin-bottom: 12px;
  border: 1px solid var(--ds-border);
}

.btn-google {
  background: #fff;
  color: #1c1814;
}

.btn-discord {
  background: #5865f2;
  color: #fff;
  border-color: #5865f2;
}

.auth-note {
  margin: 16px 0 0;
  text-align: center;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ds-muted);
}

.auth-oauth-wrap {
  margin-top: 4px;
}

.notice.error {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.25);
  color: #fca5a5;
}

.auth-bg {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.auth-bg-grid {
  position: absolute;
  inset: -6%;
  display: grid;
  grid-template-columns: repeat(2, minmax(200px, 1fr));
  gap: 18px;
  padding: 18px;
  z-index: 0;
}

@media (min-width: 640px) {
  .auth-bg-grid {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .auth-bg-grid {
    grid-template-columns: repeat(4, minmax(240px, 1fr));
    gap: 22px;
  }
}

.auth-col {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: fit-content;
}

.auth-col-up { animation: auth-scroll-up 48s linear infinite; }
.auth-col-down { animation: auth-scroll-down 54s linear infinite; }
.auth-col-up-fast { animation: auth-scroll-up 38s linear infinite; }
.auth-col-down-slow { animation: auth-scroll-down 60s linear infinite; }

@keyframes auth-scroll-up {
  from { transform: translateY(0); }
  to { transform: translateY(-50%); }
}
@keyframes auth-scroll-down {
  from { transform: translateY(-50%); }
  to { transform: translateY(0); }
}

.auth-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 130px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #18181c;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4);
}

.auth-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.1) brightness(0.92);
}

.auth-card-label {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-gold);
  background: rgba(0, 0, 0, 0.62);
  border: 1px solid rgba(200, 200, 208, 0.35);
  backdrop-filter: blur(6px);
}

.auth-bg-tint {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 12, 0.28);
  z-index: 1;
}

.auth-bg-radial {
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse 55% 50% at 50% 42%,
    rgba(10, 10, 12, 0.05) 0%,
    rgba(10, 10, 12, 0.42) 72%,
    rgba(10, 10, 12, 0.72) 100%
  );
  z-index: 2;
}

.auth-card.is-broken {
  display: none;
}

.auth-bg-fallback {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(135deg, rgba(200, 200, 208, 0.08) 0%, transparent 45%),
    linear-gradient(225deg, rgba(200, 200, 208, 0.06) 0%, transparent 45%),
    #101014;
}

@media (max-width: 480px) {
  .auth-screen { padding: 16px 12px 28px; }
  .auth-back { top: 12px; left: 12px; padding: 8px 12px; font-size: 11px; }
  .auth-panel { padding: 24px 18px; border-radius: 18px; }
  .auth-panel--wizard { max-width: 100%; }
  .auth-panel h1 { font-size: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-col-up, .auth-col-down, .auth-col-up-fast, .auth-col-down-slow { animation: none; }
}

/* —— Username setup —— */
.auth-panel--username { max-width: 440px; }

.auth-step-badge {
  display: inline-block;
  margin: 0 auto 12px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand-gold);
  background: var(--brand-gold-soft);
  border: 1px solid rgba(200, 200, 208, 0.35);
}

.auth-panel--username h1 { margin-top: 0; }

.username-form { margin-top: 4px; }

.username-label {
  display: block;
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ds-muted);
}

.username-field {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 4px 16px 4px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.username-field:focus-within {
  border-color: rgba(200, 200, 208, 0.55);
  box-shadow: 0 0 0 3px rgba(200, 200, 208, 0.12);
  background: rgba(0, 0, 0, 0.48);
}

.username-field.is-valid {
  border-color: rgba(74, 222, 128, 0.45);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.08);
}

.username-field.is-invalid {
  border-color: rgba(248, 113, 113, 0.5);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.1);
}

.username-prefix {
  font-size: 18px;
  font-weight: 700;
  color: var(--brand-gold);
  user-select: none;
  flex-shrink: 0;
}

.username-input {
  flex: 1;
  min-width: 0;
  padding: 14px 8px;
  border: none;
  background: transparent;
  color: var(--ds-text);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  outline: none;
}

.username-input::placeholder {
  color: rgba(255, 255, 255, 0.28);
  font-weight: 500;
}

.username-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.username-field.is-valid .username-status {
  background: #4ade80;
  box-shadow: 0 0 10px rgba(74, 222, 128, 0.55);
}

.username-field.is-invalid .username-status {
  background: #f87171;
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.45);
}

.username-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ds-muted);
}

.username-counter { font-variant-numeric: tabular-nums; }

.username-rules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 20px;
}

.username-rule {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.username-rule i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.username-rule.is-ok {
  color: #86efac;
  border-color: rgba(74, 222, 128, 0.25);
  background: rgba(74, 222, 128, 0.08);
}

.username-rule.is-ok i { background: #4ade80; }

.btn-username-submit {
  position: relative;
  width: 100%;
  margin-top: 4px;
  padding: 15px 20px;
  border: none;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #1c1814;
  background: linear-gradient(135deg, #e8e8ec 0%, #c8c8d0 45%, #8a8a94 100%);
  box-shadow: 0 8px 28px rgba(200, 200, 208, 0.28);
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.btn-username-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 32px rgba(200, 200, 208, 0.35);
}

.btn-username-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-username-submit.is-loading .btn-label { opacity: 0; }
.btn-username-submit.is-loading .btn-spinner {
  opacity: 1;
}

.btn-spinner {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(28, 24, 20, 0.2);
  border-top-color: #1c1814;
  border-radius: 50%;
  opacity: 0;
  animation: username-spin 0.7s linear infinite;
}

@keyframes username-spin {
  to { transform: rotate(360deg); }
}
