:root {
  --auth-green: #02b757;
  --auth-green-dark: #019648;
  --auth-gold: #ffc936;
  --auth-panel: #232845;
  --auth-text: #eef1ff;
  --auth-radius: 16px;
  --auth-radius-sm: 10px;
}

.topbar-auth {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.auth-login-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid rgba(255, 201, 54, 0.35);
  border-radius: var(--auth-radius-sm);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--auth-text);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.06);
  transition: color 0.15s, background 0.15s, border-color 0.15s, transform 0.15s;
}

.auth-login-btn:hover {
  color: #fff;
  background: rgba(255, 201, 54, 0.12);
  border-color: rgba(255, 201, 54, 0.45);
  transform: translateY(-1px);
}

.auth-user-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid rgba(255, 201, 54, 0.28);
  border-radius: var(--auth-radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: var(--auth-text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.auth-user-btn:hover {
  background: rgba(255, 201, 54, 0.1);
  border-color: rgba(255, 201, 54, 0.4);
}

.auth-user-btn img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.auth-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.auth-modal {
  width: min(100%, 440px);
  background: var(--auth-panel);
  border: 2px solid rgba(255, 201, 54, 0.35);
  border-radius: var(--auth-radius);
  padding: 26px 26px 22px;
  color: var(--auth-text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transform: translateY(10px);
  transition: transform 0.22s;
}

.auth-modal-backdrop.open .auth-modal {
  transform: translateY(0);
}

.auth-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.auth-modal-head h2 {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--auth-gold);
}

.auth-modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--auth-radius-sm);
  background: rgba(255, 255, 255, 0.06);
  color: rgba(238, 241, 255, 0.85);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.auth-modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 201, 54, 0.3);
  color: #fff;
}

.auth-modal-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(238, 241, 255, 0.65);
  margin-bottom: 8px;
}

.auth-modal-input {
  width: 100%;
  padding: 13px 15px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--auth-radius-sm);
  background: rgba(0, 0, 0, 0.22);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--auth-text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.auth-modal-input:focus {
  border-color: rgba(255, 201, 54, 0.45);
  box-shadow: 0 0 0 3px rgba(255, 201, 54, 0.12);
}

.auth-modal-input::placeholder {
  color: rgba(238, 241, 255, 0.35);
  font-weight: 500;
}

.auth-avatars {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 16px;
  min-height: 0;
}

.auth-avatars.loading {
  opacity: 0.6;
  pointer-events: none;
}

.auth-avatars-status {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(238, 241, 255, 0.5);
  padding: 12px 8px;
}

.auth-avatar-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 6px 8px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--auth-radius-sm);
  background: rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s, box-shadow 0.15s;
}

.auth-avatar-option:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 201, 54, 0.25);
  background: rgba(255, 255, 255, 0.04);
}

.auth-avatar-option.selected {
  border-color: rgba(255, 201, 54, 0.55);
  background: rgba(255, 201, 54, 0.1);
  box-shadow: 0 4px 16px rgba(255, 201, 54, 0.15);
}

.auth-avatar-option img {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.auth-avatar-option span {
  font-size: 0.68rem;
  font-weight: 700;
  color: rgba(238, 241, 255, 0.72);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-modal-submit {
  width: 100%;
  margin-top: 18px;
  padding: 14px 20px;
  border: none;
  border-bottom: 4px solid var(--auth-green-dark);
  border-radius: 14px;
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, #03d46a 0%, var(--auth-green) 55%, var(--auth-green-dark) 100%);
  box-shadow: 0 4px 16px rgba(2, 183, 87, 0.35);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}

.auth-modal-submit:disabled {
  background: #4a5270;
  border-bottom-color: #3a4060;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
  opacity: 1;
}

.auth-modal-submit:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(2, 183, 87, 0.45);
}

.auth-modal-submit:not(:disabled):active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.auth-modal-error {
  margin-top: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #ff6b6b;
  min-height: 1.2em;
}

.auth-modal-hint {
  margin-top: 12px;
  font-size: 0.75rem;
  color: rgba(238, 241, 255, 0.45);
  text-align: center;
  line-height: 1.4;
}

.auth-modal-hint--welcome {
  color: rgba(255, 201, 54, 0.9);
  font-weight: 700;
}

.auth-welcome-back {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border: 2px solid rgba(255, 201, 54, 0.35);
  border-radius: var(--auth-radius-sm);
  background: rgba(255, 201, 54, 0.08);
  text-align: center;
}

.auth-welcome-back img {
  width: 88px;
  height: 88px;
  border-radius: 16px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(255, 201, 54, 0.35);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.auth-welcome-back__title {
  font-family: 'Fredoka', 'Nunito', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--auth-gold);
}

.auth-welcome-back__name {
  font-size: 0.88rem;
  font-weight: 700;
  color: rgba(238, 241, 255, 0.85);
}

.auth-welcome-back__password-label {
  width: 100%;
  margin-top: 8px;
  margin-bottom: 0;
  text-align: left;
}

.auth-welcome-back__password {
  width: 100%;
}

.auth-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  z-index: 1100;
  transform: translateX(-50%) translateY(12px);
  padding: 12px 20px;
  border-radius: 12px;
  background: rgba(35, 40, 69, 0.98);
  border: 1px solid rgba(255, 201, 54, 0.35);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.auth-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.auth-user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  padding: 6px;
  border-radius: var(--auth-radius-sm);
  background: rgba(18, 22, 43, 0.98);
  border: 1px solid rgba(255, 201, 54, 0.22);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
  z-index: 120;
}

.auth-user-menu.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.auth-user-menu button {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: rgba(238, 241, 255, 0.9);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.auth-user-menu button:hover {
  background: rgba(255, 201, 54, 0.1);
  color: #fff;
}

.auth-user-menu-link {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(238, 241, 255, 0.9);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
}

.auth-user-menu-link:hover {
  background: rgba(255, 201, 54, 0.1);
  color: #fff;
}

.topbar-auth-wrap {
  position: relative;
}

.auth-password-banner {
  background: linear-gradient(90deg, rgba(220, 38, 38, 0.18) 0%, rgba(255, 201, 54, 0.12) 100%);
  border-bottom: 1px solid rgba(255, 201, 54, 0.35);
  padding: 10px 0;
}

.auth-password-banner__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.auth-password-banner__text {
  font-size: 0.82rem;
  color: rgba(238, 241, 255, 0.85);
  line-height: 1.4;
}

.auth-password-banner__text strong {
  color: var(--gold);
}

.auth-password-banner__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.auth-password-banner__link {
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: var(--gold);
  color: #1a1f38;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.auth-password-banner__link:hover {
  filter: brightness(1.05);
}

.auth-password-modal .auth-modal-label:not(:first-of-type) {
  margin-top: 14px;
}

.auth-password-modal .auth-modal-submit {
  margin-top: 6px;
}

.auth-user-menu button.auth-user-menu-link {
  width: 100%;
  text-align: left;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.auth-password-banner__close {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(238, 241, 255, 0.7);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}

.auth-password-banner__close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

@media (max-width: 860px) {
  .auth-login-btn {
    padding: 7px 12px;
    font-size: 0.75rem;
  }

  .auth-user-btn {
    padding: 4px 10px 4px 4px;
    font-size: 0.75rem;
  }

  .auth-user-btn img {
    width: 24px;
    height: 24px;
  }

  .auth-modal {
    padding: 22px 18px 18px;
  }

  .auth-avatar-option img {
    width: 60px;
    height: 60px;
  }
}
